From 02edc875bb5fe46aac1a88b88eaea442cb8c97fb Mon Sep 17 00:00:00 2001 From: Artur Sawicki Date: Fri, 12 Jul 2024 13:57:29 +0200 Subject: [PATCH 1/4] Add issue for unsafe execute --- v1-preparations/ESSENTIAL_GA_OBJECTS.MD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v1-preparations/ESSENTIAL_GA_OBJECTS.MD b/v1-preparations/ESSENTIAL_GA_OBJECTS.MD index 99173a1c05..9ae3bebb27 100644 --- a/v1-preparations/ESSENTIAL_GA_OBJECTS.MD +++ b/v1-preparations/ESSENTIAL_GA_OBJECTS.MD @@ -20,7 +20,7 @@ newer provider versions. We will address these while working on the given object | RESOURCE MONITOR | ❌ | [#1990](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1990), [#1832](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1832), [#1821](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1821), [#1754](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1754), [#1716](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1716), [#1714](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1714), [#1624](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1624), [#1500](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1500), [#1175](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1175) | | ROLE | 👨‍💻 | - | | SECURITY INTEGRATION | 👨‍💻 | [#2855](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2855), [#2719](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2719), [#2568](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2568), [#2177](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2177), [#1851](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1851), [#1773](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1773), [#1741](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1741), [#1637](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1637), [#1503](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1503), [#1498](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1498), [#1421](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1421), [#1224](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1224) | -| USER | 👨‍💻 | [#2902](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2902), [#2817](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2817), [#2662](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2662), [#1572](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1572), [#1535](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1535), [#1155](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1155) | +| USER | 👨‍💻 | [#2902](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2902), [#2817](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2817), [#2662](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2662), [#1572](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1572), [#1535](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1535), [#1155](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1155) | | WAREHOUSE | 🚀 | issues in the older versions: [resources](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues?q=label%3Aresource%3Awarehouse+) and [datasources](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues?q=label%3Adata_source%3Awarehouses+) | | FUNCTION | ❌ | [2859](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2859), [#2735](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2735), [#2426](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2426), [#1479](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1479), [#1393](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1393), [#1208](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1208), [#1079](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1079) | | MASKING POLICY | ❌ | [#2236](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2236), [#2035](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2035), [#1799](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1799), [#1764](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1764), [#1656](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1656), [#1444](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1444), [#1422](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1422), [#1097](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1097) | @@ -34,5 +34,5 @@ newer provider versions. We will address these while working on the given object | TAG | ❌ | [#2598](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2598), [#1910](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1910), [#1909](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1909), [#1862](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1862), [#1806](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1806), [#1657](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1657), [#1496](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1496), [#1443](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1443), [#1394](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1394), [#1372](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1372), [#1074](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1074) | | TASK | ❌ | [#1419](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1419), [#1250](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1250), [#1194](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1194), [#1088](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1088) | | VIEW | ❌ | [#2430](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2430), [#2085](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2085), [#2055](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2055), [#2031](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2031), [#1526](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1526), [#1253](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1253), [#1049](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1049) | -| snowflake_unsafe_execute | ❌ | - | +| snowflake_unsafe_execute | ❌ | [#https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2934](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2934) | From f17f616fd3979e07e3165e097a4a6e315c9efa36 Mon Sep 17 00:00:00 2001 From: Artur Sawicki Date: Fri, 12 Jul 2024 15:23:21 +0200 Subject: [PATCH 2/4] Add missing session parameters --- pkg/sdk/parameters.go | 314 ++++++++++++++++++++------------ pkg/sdk/parameters_impl.go | 297 +++++++++++++++--------------- pkg/sdk/parameters_impl_test.go | 28 ++- 3 files changed, 373 insertions(+), 266 deletions(-) diff --git a/pkg/sdk/parameters.go b/pkg/sdk/parameters.go index 4f178bc73f..75ec5d62e7 100644 --- a/pkg/sdk/parameters.go +++ b/pkg/sdk/parameters.go @@ -430,45 +430,62 @@ const ( type SessionParameter string const ( - SessionParameterAbortDetachedQuery SessionParameter = "ABORT_DETACHED_QUERY" - SessionParameterAutocommit SessionParameter = "AUTOCOMMIT" - SessionParameterBinaryInputFormat SessionParameter = "BINARY_INPUT_FORMAT" - SessionParameterBinaryOutputFormat SessionParameter = "BINARY_OUTPUT_FORMAT" - SessionParameterClientMetadataRequestUseConnectionCtx SessionParameter = "CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX" - SessionParameterClientMetadataUseSessionDatabase SessionParameter = "CLIENT_METADATA_USE_SESSION_DATABASE" - SessionParameterClientResultColumnCaseInsensitive SessionParameter = "CLIENT_RESULT_COLUMN_CASE_INSENSITIVE" - SessionParameterDateInputFormat SessionParameter = "DATE_INPUT_FORMAT" - SessionParameterGeographyOutputFormat SessionParameter = "GEOGRAPHY_OUTPUT_FORMAT" - SessionParameterDateOutputFormat SessionParameter = "DATE_OUTPUT_FORMAT" - SessionParameterErrorOnNondeterministicMerge SessionParameter = "ERROR_ON_NONDETERMINISTIC_MERGE" - SessionParameterErrorOnNondeterministicUpdate SessionParameter = "ERROR_ON_NONDETERMINISTIC_UPDATE" - SessionParameterJSONIndent SessionParameter = "JSON_INDENT" - SessionParameterLockTimeout SessionParameter = "LOCK_TIMEOUT" - SessionParameterMultiStatementCount SessionParameter = "MULTI_STATEMENT_COUNT" - SessionParameterQueryTag SessionParameter = "QUERY_TAG" - SessionParameterQuotedIdentifiersIgnoreCase SessionParameter = "QUOTED_IDENTIFIERS_IGNORE_CASE" - SessionParameterRowsPerResultset SessionParameter = "ROWS_PER_RESULTSET" - SessionParameterS3StageVpceDnsName SessionParameter = "S3_STAGE_VPCE_DNS_NAME" - SessionParameterSimulatedDataSharingConsumer SessionParameter = "SIMULATED_DATA_SHARING_CONSUMER" - SessionParameterStatementTimeoutInSeconds SessionParameter = "STATEMENT_TIMEOUT_IN_SECONDS" - SessionParameterStrictJSONOutput SessionParameter = "STRICT_JSON_OUTPUT" - SessionParameterTimeInputFormat SessionParameter = "TIME_INPUT_FORMAT" - SessionParameterTimeOutputFormat SessionParameter = "TIME_OUTPUT_FORMAT" - SessionParameterTimestampDayIsAlways24h SessionParameter = "TIMESTAMP_DAY_IS_ALWAYS_24H" - SessionParameterTimestampInputFormat SessionParameter = "TIMESTAMP_INPUT_FORMAT" - SessionParameterTimestampLTZOutputFormat SessionParameter = "TIMESTAMP_LTZ_OUTPUT_FORMAT" - SessionParameterTimestampNTZOutputFormat SessionParameter = "TIMESTAMP_NTZ_OUTPUT_FORMAT" - SessionParameterTimestampOutputFormat SessionParameter = "TIMESTAMP_OUTPUT_FORMAT" - SessionParameterTimestampTypeMapping SessionParameter = "TIMESTAMP_TYPE_MAPPING" - SessionParameterTimestampTZOutputFormat SessionParameter = "TIMESTAMP_TZ_OUTPUT_FORMAT" - SessionParameterTimezone SessionParameter = "TIMEZONE" - SessionParameterTransactionAbortOnError SessionParameter = "TRANSACTION_ABORT_ON_ERROR" - SessionParameterTransactionDefaultIsolationLevel SessionParameter = "TRANSACTION_DEFAULT_ISOLATION_LEVEL" - SessionParameterTwoDigitCenturyStart SessionParameter = "TWO_DIGIT_CENTURY_START" - SessionParameterUnsupportedDDLAction SessionParameter = "UNSUPPORTED_DDL_ACTION" - SessionParameterUseCachedResult SessionParameter = "USE_CACHED_RESULT" - SessionParameterWeekOfYearPolicy SessionParameter = "WEEK_OF_YEAR_POLICY" - SessionParameterWeekStart SessionParameter = "WEEK_START" + SessionParameterAbortDetachedQuery SessionParameter = "ABORT_DETACHED_QUERY" + SessionParameterAutocommit SessionParameter = "AUTOCOMMIT" + SessionParameterBinaryInputFormat SessionParameter = "BINARY_INPUT_FORMAT" + SessionParameterBinaryOutputFormat SessionParameter = "BINARY_OUTPUT_FORMAT" + SessionParameterClientMemoryLimit SessionParameter = "CLIENT_MEMORY_LIMIT" + SessionParameterClientMetadataRequestUseConnectionCtx SessionParameter = "CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX" + SessionParameterClientPrefetchThreads SessionParameter = "CLIENT_PREFETCH_THREADS" + SessionParameterClientResultChunkSize SessionParameter = "CLIENT_RESULT_CHUNK_SIZE" + SessionParameterClientResultColumnCaseInsensitive SessionParameter = "CLIENT_RESULT_COLUMN_CASE_INSENSITIVE" + SessionParameterClientMetadataUseSessionDatabase SessionParameter = "CLIENT_METADATA_USE_SESSION_DATABASE" + SessionParameterClientSessionKeepAlive SessionParameter = "CLIENT_SESSION_KEEP_ALIVE" + SessionParameterClientSessionKeepAliveHeartbeatFrequency SessionParameter = "CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY" + SessionParameterClientTimestampTypeMapping SessionParameter = "CLIENT_TIMESTAMP_TYPE_MAPPING" + SessionParameterDateInputFormat SessionParameter = "DATE_INPUT_FORMAT" + SessionParameterDateOutputFormat SessionParameter = "DATE_OUTPUT_FORMAT" + SessionParameterEnableUnloadPhysicalTypeOptimization SessionParameter = "ENABLE_UNLOAD_PHYSICAL_TYPE_OPTIMIZATION" + SessionParameterErrorOnNondeterministicMerge SessionParameter = "ERROR_ON_NONDETERMINISTIC_MERGE" + SessionParameterErrorOnNondeterministicUpdate SessionParameter = "ERROR_ON_NONDETERMINISTIC_UPDATE" + SessionParameterGeographyOutputFormat SessionParameter = "GEOGRAPHY_OUTPUT_FORMAT" + SessionParameterGeometryOutputFormat SessionParameter = "GEOMETRY_OUTPUT_FORMAT" + SessionParameterJdbcTreatDecimalAsInt SessionParameter = "JDBC_TREAT_DECIMAL_AS_INT" + SessionParameterJdbcTreatTimestampNtzAsUtc SessionParameter = "JDBC_TREAT_TIMESTAMP_NTZ_AS_UTC" + SessionParameterJdbcUseSessionTimezone SessionParameter = "JDBC_USE_SESSION_TIMEZONE" + SessionParameterJSONIndent SessionParameter = "JSON_INDENT" + SessionParameterLockTimeout SessionParameter = "LOCK_TIMEOUT" + SessionParameterLogLevel SessionParameter = "LOG_LEVEL" + SessionParameterMultiStatementCount SessionParameter = "MULTI_STATEMENT_COUNT" + SessionParameterNoorderSequenceAsDefault SessionParameter = "NOORDER_SEQUENCE_AS_DEFAULT" + SessionParameterOdbcTreatDecimalAsInt SessionParameter = "ODBC_TREAT_DECIMAL_AS_INT" + SessionParameterQueryTag SessionParameter = "QUERY_TAG" + SessionParameterQuotedIdentifiersIgnoreCase SessionParameter = "QUOTED_IDENTIFIERS_IGNORE_CASE" + SessionParameterRowsPerResultset SessionParameter = "ROWS_PER_RESULTSET" + SessionParameterS3StageVpceDnsName SessionParameter = "S3_STAGE_VPCE_DNS_NAME" + SessionParameterSearchPath SessionParameter = "SEARCH_PATH" + SessionParameterSimulatedDataSharingConsumer SessionParameter = "SIMULATED_DATA_SHARING_CONSUMER" + SessionParameterStatementQueuedTimeoutInSeconds SessionParameter = "STATEMENT_QUEUED_TIMEOUT_IN_SECONDS" + SessionParameterStatementTimeoutInSeconds SessionParameter = "STATEMENT_TIMEOUT_IN_SECONDS" + SessionParameterStrictJSONOutput SessionParameter = "STRICT_JSON_OUTPUT" + SessionParameterTimestampDayIsAlways24h SessionParameter = "TIMESTAMP_DAY_IS_ALWAYS_24H" + SessionParameterTimestampInputFormat SessionParameter = "TIMESTAMP_INPUT_FORMAT" + SessionParameterTimestampLTZOutputFormat SessionParameter = "TIMESTAMP_LTZ_OUTPUT_FORMAT" + SessionParameterTimestampNTZOutputFormat SessionParameter = "TIMESTAMP_NTZ_OUTPUT_FORMAT" + SessionParameterTimestampOutputFormat SessionParameter = "TIMESTAMP_OUTPUT_FORMAT" + SessionParameterTimestampTypeMapping SessionParameter = "TIMESTAMP_TYPE_MAPPING" + SessionParameterTimestampTZOutputFormat SessionParameter = "TIMESTAMP_TZ_OUTPUT_FORMAT" + SessionParameterTimezone SessionParameter = "TIMEZONE" + SessionParameterTimeInputFormat SessionParameter = "TIME_INPUT_FORMAT" + SessionParameterTimeOutputFormat SessionParameter = "TIME_OUTPUT_FORMAT" + SessionParameterTraceLevel SessionParameter = "TRACE_LEVEL" + SessionParameterTransactionAbortOnError SessionParameter = "TRANSACTION_ABORT_ON_ERROR" + SessionParameterTransactionDefaultIsolationLevel SessionParameter = "TRANSACTION_DEFAULT_ISOLATION_LEVEL" + SessionParameterTwoDigitCenturyStart SessionParameter = "TWO_DIGIT_CENTURY_START" + SessionParameterUnsupportedDDLAction SessionParameter = "UNSUPPORTED_DDL_ACTION" + SessionParameterUseCachedResult SessionParameter = "USE_CACHED_RESULT" + SessionParameterWeekOfYearPolicy SessionParameter = "WEEK_OF_YEAR_POLICY" + SessionParameterWeekStart SessionParameter = "WEEK_START" ) type ObjectParameter string @@ -626,6 +643,17 @@ const ( GeographyOutputFormatWKT GeographyOutputFormat = "WKT" GeographyOutputFormatWKB GeographyOutputFormat = "WKB" GeographyOutputFormatEWKT GeographyOutputFormat = "EWKT" + GeographyOutputFormatEWKB GeographyOutputFormat = "EWKB" +) + +type GeometryOutputFormat string + +const ( + GeometryOutputFormatGeoJSON GeometryOutputFormat = "GeoJSON" + GeometryOutputFormatWKT GeometryOutputFormat = "WKT" + GeometryOutputFormatWKB GeometryOutputFormat = "WKB" + GeometryOutputFormatEWKT GeometryOutputFormat = "EWKT" + GeometryOutputFormatEWKB GeometryOutputFormat = "EWKB" ) type BinaryInputFormat string @@ -643,6 +671,21 @@ const ( BinaryOutputFormatBase64 BinaryOutputFormat = "BASE64" ) +type ClientTimestampTypeMapping string + +const ( + ClientTimestampTypeMappingLtz ClientTimestampTypeMapping = "TIMESTAMP_LTZ" + ClientTimestampTypeMappingNtz ClientTimestampTypeMapping = "TIMESTAMP_NTZ" +) + +type TimestampTypeMapping string + +const ( + TimestampTypeMappingLtz TimestampTypeMapping = "TIMESTAMP_LTZ" + TimestampTypeMappingNtz TimestampTypeMapping = "TIMESTAMP_NTZ" + TimestampTypeMappingTz TimestampTypeMapping = "TIMESTAMP_TZ" +) + type TransactionDefaultIsolationLevel string const ( @@ -658,45 +701,62 @@ const ( // SessionParameters is based on https://docs.snowflake.com/en/sql-reference/parameters#session-parameters. type SessionParameters struct { - AbortDetachedQuery *bool `ddl:"parameter" sql:"ABORT_DETACHED_QUERY"` - Autocommit *bool `ddl:"parameter" sql:"AUTOCOMMIT"` - BinaryInputFormat *BinaryInputFormat `ddl:"parameter,single_quotes" sql:"BINARY_INPUT_FORMAT"` - BinaryOutputFormat *BinaryOutputFormat `ddl:"parameter,single_quotes" sql:"BINARY_OUTPUT_FORMAT"` - ClientMetadataRequestUseConnectionCtx *bool `ddl:"parameter" sql:"CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX"` - ClientMetadataUseSessionDatabase *bool `ddl:"parameter" sql:"CLIENT_METADATA_USE_SESSION_DATABASE"` - ClientResultColumnCaseInsensitive *bool `ddl:"parameter" sql:"CLIENT_RESULT_COLUMN_CASE_INSENSITIVE"` - DateInputFormat *string `ddl:"parameter,single_quotes" sql:"DATE_INPUT_FORMAT"` - DateOutputFormat *string `ddl:"parameter,single_quotes" sql:"DATE_OUTPUT_FORMAT"` - ErrorOnNondeterministicMerge *bool `ddl:"parameter" sql:"ERROR_ON_NONDETERMINISTIC_MERGE"` - ErrorOnNondeterministicUpdate *bool `ddl:"parameter" sql:"ERROR_ON_NONDETERMINISTIC_UPDATE"` - GeographyOutputFormat *GeographyOutputFormat `ddl:"parameter,single_quotes" sql:"GEOGRAPHY_OUTPUT_FORMAT"` - JSONIndent *int `ddl:"parameter" sql:"JSON_INDENT"` - LockTimeout *int `ddl:"parameter" sql:"LOCK_TIMEOUT"` - MultiStatementCount *int `ddl:"parameter" sql:"MULTI_STATEMENT_COUNT"` - QueryTag *string `ddl:"parameter,single_quotes" sql:"QUERY_TAG"` - QuotedIdentifiersIgnoreCase *bool `ddl:"parameter" sql:"QUOTED_IDENTIFIERS_IGNORE_CASE"` - RowsPerResultset *int `ddl:"parameter" sql:"ROWS_PER_RESULTSET"` - S3StageVpceDnsName *string `ddl:"parameter,single_quotes" sql:"S3_STAGE_VPCE_DNS_NAME"` - SimulatedDataSharingConsumer *string `ddl:"parameter,single_quotes" sql:"SIMULATED_DATA_SHARING_CONSUMER"` - StatementTimeoutInSeconds *int `ddl:"parameter" sql:"STATEMENT_TIMEOUT_IN_SECONDS"` - StrictJSONOutput *bool `ddl:"parameter" sql:"STRICT_JSON_OUTPUT"` - TimestampDayIsAlways24h *bool `ddl:"parameter" sql:"TIMESTAMP_DAY_IS_ALWAYS_24H"` - TimestampInputFormat *string `ddl:"parameter,single_quotes" sql:"TIMESTAMP_INPUT_FORMAT"` - TimestampLTZOutputFormat *string `ddl:"parameter,single_quotes" sql:"TIMESTAMP_LTZ_OUTPUT_FORMAT"` - TimestampNTZOutputFormat *string `ddl:"parameter,single_quotes" sql:"TIMESTAMP_NTZ_OUTPUT_FORMAT"` - TimestampOutputFormat *string `ddl:"parameter,single_quotes" sql:"TIMESTAMP_OUTPUT_FORMAT"` - TimestampTypeMapping *string `ddl:"parameter,single_quotes" sql:"TIMESTAMP_TYPE_MAPPING"` - TimestampTZOutputFormat *string `ddl:"parameter,single_quotes" sql:"TIMESTAMP_TZ_OUTPUT_FORMAT"` - Timezone *string `ddl:"parameter,single_quotes" sql:"TIMEZONE"` - TimeInputFormat *string `ddl:"parameter,single_quotes" sql:"TIME_INPUT_FORMAT"` - TimeOutputFormat *string `ddl:"parameter,single_quotes" sql:"TIME_OUTPUT_FORMAT"` - TransactionAbortOnError *bool `ddl:"parameter" sql:"TRANSACTION_ABORT_ON_ERROR"` - TransactionDefaultIsolationLevel *TransactionDefaultIsolationLevel `ddl:"parameter,single_quotes" sql:"TRANSACTION_DEFAULT_ISOLATION_LEVEL"` - TwoDigitCenturyStart *int `ddl:"parameter" sql:"TWO_DIGIT_CENTURY_START"` - UnsupportedDDLAction *UnsupportedDDLAction `ddl:"parameter,single_quotes" sql:"UNSUPPORTED_DDL_ACTION"` - UseCachedResult *bool `ddl:"parameter" sql:"USE_CACHED_RESULT"` - WeekOfYearPolicy *int `ddl:"parameter" sql:"WEEK_OF_YEAR_POLICY"` - WeekStart *int `ddl:"parameter" sql:"WEEK_START"` + AbortDetachedQuery *bool `ddl:"parameter" sql:"ABORT_DETACHED_QUERY"` + Autocommit *bool `ddl:"parameter" sql:"AUTOCOMMIT"` + BinaryInputFormat *BinaryInputFormat `ddl:"parameter,single_quotes" sql:"BINARY_INPUT_FORMAT"` + BinaryOutputFormat *BinaryOutputFormat `ddl:"parameter,single_quotes" sql:"BINARY_OUTPUT_FORMAT"` + ClientMemoryLimit *int `ddl:"parameter" sql:"CLIENT_MEMORY_LIMIT"` + ClientMetadataRequestUseConnectionCtx *bool `ddl:"parameter" sql:"CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX"` + ClientPrefetchThreads *int `ddl:"parameter" sql:"CLIENT_PREFETCH_THREADS"` + ClientResultChunkSize *int `ddl:"parameter" sql:"CLIENT_RESULT_CHUNK_SIZE"` + ClientResultColumnCaseInsensitive *bool `ddl:"parameter" sql:"CLIENT_RESULT_COLUMN_CASE_INSENSITIVE"` + ClientMetadataUseSessionDatabase *bool `ddl:"parameter" sql:"CLIENT_METADATA_USE_SESSION_DATABASE"` + ClientSessionKeepAlive *bool `ddl:"parameter" sql:"CLIENT_SESSION_KEEP_ALIVE"` + ClientSessionKeepAliveHeartbeatFrequency *int `ddl:"parameter" sql:"CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY"` + ClientTimestampTypeMapping *ClientTimestampTypeMapping `ddl:"parameter,single_quotes" sql:"CLIENT_TIMESTAMP_TYPE_MAPPING"` + DateInputFormat *string `ddl:"parameter,single_quotes" sql:"DATE_INPUT_FORMAT"` + DateOutputFormat *string `ddl:"parameter,single_quotes" sql:"DATE_OUTPUT_FORMAT"` + EnableUnloadPhysicalTypeOptimization *bool `ddl:"parameter" sql:"ENABLE_UNLOAD_PHYSICAL_TYPE_OPTIMIZATION"` + ErrorOnNondeterministicMerge *bool `ddl:"parameter" sql:"ERROR_ON_NONDETERMINISTIC_MERGE"` + ErrorOnNondeterministicUpdate *bool `ddl:"parameter" sql:"ERROR_ON_NONDETERMINISTIC_UPDATE"` + GeographyOutputFormat *GeographyOutputFormat `ddl:"parameter,single_quotes" sql:"GEOGRAPHY_OUTPUT_FORMAT"` + GeometryOutputFormat *GeometryOutputFormat `ddl:"parameter,single_quotes" sql:"GEOMETRY_OUTPUT_FORMAT"` + JdbcTreatDecimalAsInt *bool `ddl:"parameter" sql:"JDBC_TREAT_DECIMAL_AS_INT"` + JdbcTreatTimestampNtzAsUtc *bool `ddl:"parameter" sql:"JDBC_TREAT_TIMESTAMP_NTZ_AS_UTC"` + JdbcUseSessionTimezone *bool `ddl:"parameter" sql:"JDBC_USE_SESSION_TIMEZONE"` + JSONIndent *int `ddl:"parameter" sql:"JSON_INDENT"` + LockTimeout *int `ddl:"parameter" sql:"LOCK_TIMEOUT"` + LogLevel *LogLevel `ddl:"parameter" sql:"LOG_LEVEL"` + MultiStatementCount *int `ddl:"parameter" sql:"MULTI_STATEMENT_COUNT"` + NoorderSequenceAsDefault *bool `ddl:"parameter" sql:"NOORDER_SEQUENCE_AS_DEFAULT"` + OdbcTreatDecimalAsInt *bool `ddl:"parameter" sql:"ODBC_TREAT_DECIMAL_AS_INT"` + QueryTag *string `ddl:"parameter,single_quotes" sql:"QUERY_TAG"` + QuotedIdentifiersIgnoreCase *bool `ddl:"parameter" sql:"QUOTED_IDENTIFIERS_IGNORE_CASE"` + RowsPerResultset *int `ddl:"parameter" sql:"ROWS_PER_RESULTSET"` + S3StageVpceDnsName *string `ddl:"parameter,single_quotes" sql:"S3_STAGE_VPCE_DNS_NAME"` + SearchPath *string `ddl:"parameter,single_quotes" sql:"SEARCH_PATH"` + SimulatedDataSharingConsumer *string `ddl:"parameter,single_quotes" sql:"SIMULATED_DATA_SHARING_CONSUMER"` + StatementQueuedTimeoutInSeconds *int `ddl:"parameter" sql:"STATEMENT_QUEUED_TIMEOUT_IN_SECONDS"` + StatementTimeoutInSeconds *int `ddl:"parameter" sql:"STATEMENT_TIMEOUT_IN_SECONDS"` + StrictJSONOutput *bool `ddl:"parameter" sql:"STRICT_JSON_OUTPUT"` + TimestampDayIsAlways24h *bool `ddl:"parameter" sql:"TIMESTAMP_DAY_IS_ALWAYS_24H"` + TimestampInputFormat *string `ddl:"parameter,single_quotes" sql:"TIMESTAMP_INPUT_FORMAT"` + TimestampLTZOutputFormat *string `ddl:"parameter,single_quotes" sql:"TIMESTAMP_LTZ_OUTPUT_FORMAT"` + TimestampNTZOutputFormat *string `ddl:"parameter,single_quotes" sql:"TIMESTAMP_NTZ_OUTPUT_FORMAT"` + TimestampOutputFormat *string `ddl:"parameter,single_quotes" sql:"TIMESTAMP_OUTPUT_FORMAT"` + TimestampTypeMapping *TimestampTypeMapping `ddl:"parameter,single_quotes" sql:"TIMESTAMP_TYPE_MAPPING"` + TimestampTZOutputFormat *string `ddl:"parameter,single_quotes" sql:"TIMESTAMP_TZ_OUTPUT_FORMAT"` + Timezone *string `ddl:"parameter,single_quotes" sql:"TIMEZONE"` + TimeInputFormat *string `ddl:"parameter,single_quotes" sql:"TIME_INPUT_FORMAT"` + TimeOutputFormat *string `ddl:"parameter,single_quotes" sql:"TIME_OUTPUT_FORMAT"` + TraceLevel *TraceLevel `ddl:"parameter,single_quotes" sql:"TRACE_LEVEL"` + TransactionAbortOnError *bool `ddl:"parameter" sql:"TRANSACTION_ABORT_ON_ERROR"` + TransactionDefaultIsolationLevel *TransactionDefaultIsolationLevel `ddl:"parameter,single_quotes" sql:"TRANSACTION_DEFAULT_ISOLATION_LEVEL"` + TwoDigitCenturyStart *int `ddl:"parameter" sql:"TWO_DIGIT_CENTURY_START"` + UnsupportedDDLAction *UnsupportedDDLAction `ddl:"parameter,single_quotes" sql:"UNSUPPORTED_DDL_ACTION"` + UseCachedResult *bool `ddl:"parameter" sql:"USE_CACHED_RESULT"` + WeekOfYearPolicy *int `ddl:"parameter" sql:"WEEK_OF_YEAR_POLICY"` + WeekStart *int `ddl:"parameter" sql:"WEEK_START"` } func (v *SessionParameters) validate() error { @@ -740,49 +800,67 @@ func (v *SessionParameters) validate() error { } type SessionParametersUnset struct { - AbortDetachedQuery *bool `ddl:"keyword" sql:"ABORT_DETACHED_QUERY"` - Autocommit *bool `ddl:"keyword" sql:"AUTOCOMMIT"` - BinaryInputFormat *bool `ddl:"keyword" sql:"BINARY_INPUT_FORMAT"` - BinaryOutputFormat *bool `ddl:"keyword" sql:"BINARY_OUTPUT_FORMAT"` - ClientMetadataRequestUseConnectionCtx *bool `ddl:"keyword" sql:"CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX"` - ClientMetadataUseSessionDatabase *bool `ddl:"keyword" sql:"CLIENT_METADATA_USE_SESSION_DATABASE"` - ClientResultColumnCaseInsensitive *bool `ddl:"keyword" sql:"CLIENT_RESULT_COLUMN_CASE_INSENSITIVE"` - DateInputFormat *bool `ddl:"keyword" sql:"DATE_INPUT_FORMAT"` - DateOutputFormat *bool `ddl:"keyword" sql:"DATE_OUTPUT_FORMAT"` - ErrorOnNondeterministicMerge *bool `ddl:"keyword" sql:"ERROR_ON_NONDETERMINISTIC_MERGE"` - ErrorOnNondeterministicUpdate *bool `ddl:"keyword" sql:"ERROR_ON_NONDETERMINISTIC_UPDATE"` - GeographyOutputFormat *bool `ddl:"keyword" sql:"GEOGRAPHY_OUTPUT_FORMAT"` - JSONIndent *bool `ddl:"keyword" sql:"JSON_INDENT"` - LockTimeout *bool `ddl:"keyword" sql:"LOCK_TIMEOUT"` - MultiStatementCount *bool `ddl:"keyword" sql:"MULTI_STATEMENT_COUNT"` - QueryTag *bool `ddl:"keyword" sql:"QUERY_TAG"` - QuotedIdentifiersIgnoreCase *bool `ddl:"keyword" sql:"QUOTED_IDENTIFIERS_IGNORE_CASE"` - RowsPerResultset *bool `ddl:"keyword" sql:"ROWS_PER_RESULTSET"` - S3StageVpceDnsName *bool `ddl:"keyword" sql:"S3_STAGE_VPCE_DNS_NAME"` - SimulatedDataSharingConsumer *bool `ddl:"keyword" sql:"SIMULATED_DATA_SHARING_CONSUMER"` - StatementTimeoutInSeconds *bool `ddl:"keyword" sql:"STATEMENT_TIMEOUT_IN_SECONDS"` - StrictJSONOutput *bool `ddl:"keyword" sql:"STRICT_JSON_OUTPUT"` - TimestampDayIsAlways24h *bool `ddl:"keyword" sql:"TIMESTAMP_DAY_IS_ALWAYS_24H"` - TimestampInputFormat *bool `ddl:"keyword" sql:"TIMESTAMP_INPUT_FORMAT"` - TimestampLTZOutputFormat *bool `ddl:"keyword" sql:"TIMESTAMP_LTZ_OUTPUT_FORMAT"` - TimestampNTZOutputFormat *bool `ddl:"keyword" sql:"TIMESTAMP_NTZ_OUTPUT_FORMAT"` - TimestampOutputFormat *bool `ddl:"keyword" sql:"TIMESTAMP_OUTPUT_FORMAT"` - TimestampTypeMapping *bool `ddl:"keyword" sql:"TIMESTAMP_TYPE_MAPPING"` - TimestampTZOutputFormat *bool `ddl:"keyword" sql:"TIMESTAMP_TZ_OUTPUT_FORMAT"` - Timezone *bool `ddl:"keyword" sql:"TIMEZONE"` - TimeInputFormat *bool `ddl:"keyword" sql:"TIME_INPUT_FORMAT"` - TimeOutputFormat *bool `ddl:"keyword" sql:"TIME_OUTPUT_FORMAT"` - TransactionDefaultIsolationLevel *bool `ddl:"keyword" sql:"TRANSACTION_DEFAULT_ISOLATION_LEVEL"` - TwoDigitCenturyStart *bool `ddl:"keyword" sql:"TWO_DIGIT_CENTURY_START"` - UnsupportedDDLAction *bool `ddl:"keyword" sql:"UNSUPPORTED_DDL_ACTION"` - UseCachedResult *bool `ddl:"keyword" sql:"USE_CACHED_RESULT"` - WeekOfYearPolicy *bool `ddl:"keyword" sql:"WEEK_OF_YEAR_POLICY"` - WeekStart *bool `ddl:"keyword" sql:"WEEK_START"` + AbortDetachedQuery *bool `ddl:"keyword" sql:"ABORT_DETACHED_QUERY"` + Autocommit *bool `ddl:"keyword" sql:"AUTOCOMMIT"` + BinaryInputFormat *bool `ddl:"keyword" sql:"BINARY_INPUT_FORMAT"` + BinaryOutputFormat *bool `ddl:"keyword" sql:"BINARY_OUTPUT_FORMAT"` + ClientMemoryLimit *bool `ddl:"keyword" sql:"CLIENT_MEMORY_LIMIT"` + ClientMetadataRequestUseConnectionCtx *bool `ddl:"keyword" sql:"CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX"` + ClientPrefetchThreads *bool `ddl:"keyword" sql:"CLIENT_PREFETCH_THREADS"` + ClientResultChunkSize *bool `ddl:"keyword" sql:"CLIENT_RESULT_CHUNK_SIZE"` + ClientResultColumnCaseInsensitive *bool `ddl:"keyword" sql:"CLIENT_RESULT_COLUMN_CASE_INSENSITIVE"` + ClientMetadataUseSessionDatabase *bool `ddl:"keyword" sql:"CLIENT_METADATA_USE_SESSION_DATABASE"` + ClientSessionKeepAlive *bool `ddl:"keyword" sql:"CLIENT_SESSION_KEEP_ALIVE"` + ClientSessionKeepAliveHeartbeatFrequency *bool `ddl:"keyword" sql:"CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY"` + ClientTimestampTypeMapping *bool `ddl:"keyword" sql:"CLIENT_TIMESTAMP_TYPE_MAPPING"` + DateInputFormat *bool `ddl:"keyword" sql:"DATE_INPUT_FORMAT"` + DateOutputFormat *bool `ddl:"keyword" sql:"DATE_OUTPUT_FORMAT"` + EnableUnloadPhysicalTypeOptimization *bool `ddl:"keyword" sql:"ENABLE_UNLOAD_PHYSICAL_TYPE_OPTIMIZATION"` + ErrorOnNondeterministicMerge *bool `ddl:"keyword" sql:"ERROR_ON_NONDETERMINISTIC_MERGE"` + ErrorOnNondeterministicUpdate *bool `ddl:"keyword" sql:"ERROR_ON_NONDETERMINISTIC_UPDATE"` + GeographyOutputFormat *bool `ddl:"keyword" sql:"GEOGRAPHY_OUTPUT_FORMAT"` + GeometryOutputFormat *bool `ddl:"keyword" sql:"GEOMETRY_OUTPUT_FORMAT"` + JdbcTreatDecimalAsInt *bool `ddl:"keyword" sql:"JDBC_TREAT_DECIMAL_AS_INT"` + JdbcTreatTimestampNtzAsUtc *bool `ddl:"keyword" sql:"JDBC_TREAT_TIMESTAMP_NTZ_AS_UTC"` + JdbcUseSessionTimezone *bool `ddl:"keyword" sql:"JDBC_USE_SESSION_TIMEZONE"` + JSONIndent *bool `ddl:"keyword" sql:"JSON_INDENT"` + LockTimeout *bool `ddl:"keyword" sql:"LOCK_TIMEOUT"` + LogLevel *bool `ddl:"keyword" sql:"LOG_LEVEL"` + MultiStatementCount *bool `ddl:"keyword" sql:"MULTI_STATEMENT_COUNT"` + NoorderSequenceAsDefault *bool `ddl:"keyword" sql:"NOORDER_SEQUENCE_AS_DEFAULT"` + OdbcTreatDecimalAsInt *bool `ddl:"keyword" sql:"ODBC_TREAT_DECIMAL_AS_INT"` + QueryTag *bool `ddl:"keyword" sql:"QUERY_TAG"` + QuotedIdentifiersIgnoreCase *bool `ddl:"keyword" sql:"QUOTED_IDENTIFIERS_IGNORE_CASE"` + RowsPerResultset *bool `ddl:"keyword" sql:"ROWS_PER_RESULTSET"` + S3StageVpceDnsName *bool `ddl:"keyword" sql:"S3_STAGE_VPCE_DNS_NAME"` + SearchPath *bool `ddl:"keyword" sql:"SEARCH_PATH"` + SimulatedDataSharingConsumer *bool `ddl:"keyword" sql:"SIMULATED_DATA_SHARING_CONSUMER"` + StatementQueuedTimeoutInSeconds *bool `ddl:"keyword" sql:"STATEMENT_QUEUED_TIMEOUT_IN_SECONDS"` + StatementTimeoutInSeconds *bool `ddl:"keyword" sql:"STATEMENT_TIMEOUT_IN_SECONDS"` + StrictJSONOutput *bool `ddl:"keyword" sql:"STRICT_JSON_OUTPUT"` + TimestampDayIsAlways24h *bool `ddl:"keyword" sql:"TIMESTAMP_DAY_IS_ALWAYS_24H"` + TimestampInputFormat *bool `ddl:"keyword" sql:"TIMESTAMP_INPUT_FORMAT"` + TimestampLTZOutputFormat *bool `ddl:"keyword" sql:"TIMESTAMP_LTZ_OUTPUT_FORMAT"` + TimestampNTZOutputFormat *bool `ddl:"keyword" sql:"TIMESTAMP_NTZ_OUTPUT_FORMAT"` + TimestampOutputFormat *bool `ddl:"keyword" sql:"TIMESTAMP_OUTPUT_FORMAT"` + TimestampTypeMapping *bool `ddl:"keyword" sql:"TIMESTAMP_TYPE_MAPPING"` + TimestampTZOutputFormat *bool `ddl:"keyword" sql:"TIMESTAMP_TZ_OUTPUT_FORMAT"` + Timezone *bool `ddl:"keyword" sql:"TIMEZONE"` + TimeInputFormat *bool `ddl:"keyword" sql:"TIME_INPUT_FORMAT"` + TimeOutputFormat *bool `ddl:"keyword" sql:"TIME_OUTPUT_FORMAT"` + TraceLevel *bool `ddl:"keyword" sql:"TRACE_LEVEL"` + TransactionAbortOnError *bool `ddl:"keyword" sql:"TRANSACTION_ABORT_ON_ERROR"` + TransactionDefaultIsolationLevel *bool `ddl:"keyword" sql:"TRANSACTION_DEFAULT_ISOLATION_LEVEL"` + TwoDigitCenturyStart *bool `ddl:"keyword" sql:"TWO_DIGIT_CENTURY_START"` + UnsupportedDDLAction *bool `ddl:"keyword" sql:"UNSUPPORTED_DDL_ACTION"` + UseCachedResult *bool `ddl:"keyword" sql:"USE_CACHED_RESULT"` + WeekOfYearPolicy *bool `ddl:"keyword" sql:"WEEK_OF_YEAR_POLICY"` + WeekStart *bool `ddl:"keyword" sql:"WEEK_START"` } func (v *SessionParametersUnset) validate() error { - if !anyValueSet(v.AbortDetachedQuery, v.Autocommit, v.BinaryInputFormat, v.BinaryOutputFormat, v.ClientMetadataRequestUseConnectionCtx, v.ClientMetadataUseSessionDatabase, v.ClientResultColumnCaseInsensitive, v.DateInputFormat, v.DateOutputFormat, v.ErrorOnNondeterministicMerge, v.ErrorOnNondeterministicUpdate, v.GeographyOutputFormat, v.JSONIndent, v.LockTimeout, v.MultiStatementCount, v.QueryTag, v.QuotedIdentifiersIgnoreCase, v.RowsPerResultset, v.SimulatedDataSharingConsumer, v.StatementTimeoutInSeconds, v.StrictJSONOutput, v.TimestampDayIsAlways24h, v.TimestampInputFormat, v.TimestampLTZOutputFormat, v.TimestampNTZOutputFormat, v.TimestampOutputFormat, v.TimestampTypeMapping, v.TimestampTZOutputFormat, v.Timezone, v.TimeInputFormat, v.TimeOutputFormat, v.TransactionDefaultIsolationLevel, v.TwoDigitCenturyStart, v.UnsupportedDDLAction, v.UseCachedResult, v.WeekOfYearPolicy, v.WeekStart) { - return errors.Join(errAtLeastOneOf("SessionParametersUnset", "AbortDetachedQuery", "Autocommit", "BinaryInputFormat", "BinaryOutputFormat", "DateInputFormat", "DateOutputFormat", "ErrorOnNondeterministicMerge", "ErrorOnNondeterministicUpdate", "GeographyOutputFormat", "JSONIndent", "LockTimeout", "QueryTag", "RowsPerResultset", "SimulatedDataSharingConsumer", "StatementTimeoutInSeconds", "StrictJSONOutput", "TimestampDayIsAlways24h", "TimestampInputFormat", "TimestampLTZOutputFormat", "TimestampNTZOutputFormat", "TimestampOutputFormat", "TimestampTypeMapping", "TimestampTZOutputFormat", "Timezone", "TimeInputFormat", "TimeOutputFormat", "TransactionDefaultIsolationLevel", "TwoDigitCenturyStart", "UnsupportedDDLAction", "UseCachedResult", "WeekOfYearPolicy", "WeekStart")) + if !anyValueSet(v.AbortDetachedQuery, v.Autocommit, v.BinaryInputFormat, v.BinaryOutputFormat, v.ClientMemoryLimit, v.ClientMetadataRequestUseConnectionCtx, v.ClientPrefetchThreads, v.ClientResultChunkSize, v.ClientResultColumnCaseInsensitive, v.ClientMetadataUseSessionDatabase, v.ClientSessionKeepAlive, v.ClientSessionKeepAliveHeartbeatFrequency, v.ClientTimestampTypeMapping, v.DateInputFormat, v.DateOutputFormat, v.EnableUnloadPhysicalTypeOptimization, v.ErrorOnNondeterministicMerge, v.ErrorOnNondeterministicUpdate, v.GeographyOutputFormat, v.GeometryOutputFormat, v.JdbcTreatDecimalAsInt, v.JdbcTreatTimestampNtzAsUtc, v.JdbcUseSessionTimezone, v.JSONIndent, v.LockTimeout, v.LogLevel, v.MultiStatementCount, v.NoorderSequenceAsDefault, v.OdbcTreatDecimalAsInt, v.QueryTag, v.QuotedIdentifiersIgnoreCase, v.RowsPerResultset, v.S3StageVpceDnsName, v.SearchPath, v.SimulatedDataSharingConsumer, v.StatementQueuedTimeoutInSeconds, v.StatementTimeoutInSeconds, v.StrictJSONOutput, v.TimestampDayIsAlways24h, v.TimestampInputFormat, v.TimestampLTZOutputFormat, v.TimestampNTZOutputFormat, v.TimestampOutputFormat, v.TimestampTypeMapping, v.TimestampTZOutputFormat, v.Timezone, v.TimeInputFormat, v.TimeOutputFormat, v.TraceLevel, v.TransactionAbortOnError, v.TransactionDefaultIsolationLevel, v.TwoDigitCenturyStart, v.UnsupportedDDLAction, v.UseCachedResult, v.WeekOfYearPolicy, v.WeekStart) { + return errors.Join(errAtLeastOneOf("SessionParametersUnset", "AbortDetachedQuery", "Autocommit", "BinaryInputFormat", "BinaryOutputFormat", "ClientMemoryLimit", "ClientMetadataRequestUseConnectionCtx", "ClientPrefetchThreads", "ClientResultChunkSize", "ClientResultColumnCaseInsensitive", "ClientMetadataUseSessionDatabase", "ClientSessionKeepAlive", "ClientSessionKeepAliveHeartbeatFrequency", "ClientTimestampTypeMapping", "DateInputFormat", "DateOutputFormat", "EnableUnloadPhysicalTypeOptimization", "ErrorOnNondeterministicMerge", "ErrorOnNondeterministicUpdate", "GeographyOutputFormat", "GeometryOutputFormat", "JdbcTreatDecimalAsInt", "JdbcTreatTimestampNtzAsUtc", "JdbcUseSessionTimezone", "JSONIndent", "LockTimeout", "LogLevel", "MultiStatementCount", "NoorderSequenceAsDefault", "OdbcTreatDecimalAsInt", "QueryTag", "QuotedIdentifiersIgnoreCase", "RowsPerResultset", "S3StageVpceDnsName", "SearchPath", "SimulatedDataSharingConsumer", "StatementQueuedTimeoutInSeconds", "StatementTimeoutInSeconds", "StrictJSONOutput", "TimestampDayIsAlways24h", "TimestampInputFormat", "TimestampLTZOutputFormat", "TimestampNTZOutputFormat", "TimestampOutputFormat", "TimestampTypeMapping", "TimestampTZOutputFormat", "Timezone", "TimeInputFormat", "TimeOutputFormat", "TraceLevel", "TransactionAbortOnError", "TransactionDefaultIsolationLevel", "TwoDigitCenturyStart", "UnsupportedDDLAction", "UseCachedResult", "WeekOfYearPolicy", "WeekStart")) } return nil } diff --git a/pkg/sdk/parameters_impl.go b/pkg/sdk/parameters_impl.go index 50377efcf7..c36e4ce946 100644 --- a/pkg/sdk/parameters_impl.go +++ b/pkg/sdk/parameters_impl.go @@ -20,115 +20,88 @@ func GetSessionParametersFrom(params map[string]any) (*SessionParameters, error) return sessionParameters, nil } +// TODO [SNOW-1348330]: get type based on the tag in SessionParameters struct and handle in a generic way func (sessionParameters *SessionParameters) setParam(parameter SessionParameter, value string) error { + var err error switch parameter { case SessionParameterAbortDetachedQuery: - b, err := parseBooleanParameter(string(parameter), value) - if err != nil { - return err - } - sessionParameters.AbortDetachedQuery = b + err = setBooleanValue(parameter, value, &sessionParameters.AbortDetachedQuery) case SessionParameterAutocommit: - b, err := parseBooleanParameter(string(parameter), value) - if err != nil { - return err - } - sessionParameters.Autocommit = b + err = setBooleanValue(parameter, value, &sessionParameters.Autocommit) case SessionParameterBinaryInputFormat: sessionParameters.BinaryInputFormat = Pointer(BinaryInputFormat(value)) case SessionParameterBinaryOutputFormat: sessionParameters.BinaryOutputFormat = Pointer(BinaryOutputFormat(value)) + case SessionParameterClientMemoryLimit: + err = setIntegerValue(parameter, value, &sessionParameters.ClientMemoryLimit) case SessionParameterClientMetadataRequestUseConnectionCtx: - b, err := parseBooleanParameter(string(parameter), value) - if err != nil { - return err - } - sessionParameters.ClientMetadataRequestUseConnectionCtx = b - case SessionParameterClientMetadataUseSessionDatabase: - b, err := parseBooleanParameter(string(parameter), value) - if err != nil { - return err - } - sessionParameters.ClientMetadataUseSessionDatabase = b + err = setBooleanValue(parameter, value, &sessionParameters.ClientMetadataRequestUseConnectionCtx) + case SessionParameterClientPrefetchThreads: + err = setIntegerValue(parameter, value, &sessionParameters.ClientPrefetchThreads) + case SessionParameterClientResultChunkSize: + err = setIntegerValue(parameter, value, &sessionParameters.ClientResultChunkSize) case SessionParameterClientResultColumnCaseInsensitive: - b, err := parseBooleanParameter(string(parameter), value) - if err != nil { - return err - } - sessionParameters.ClientResultColumnCaseInsensitive = b + err = setBooleanValue(parameter, value, &sessionParameters.ClientResultColumnCaseInsensitive) + case SessionParameterClientMetadataUseSessionDatabase: + err = setBooleanValue(parameter, value, &sessionParameters.ClientMetadataUseSessionDatabase) + case SessionParameterClientSessionKeepAlive: + err = setBooleanValue(parameter, value, &sessionParameters.ClientSessionKeepAlive) + case SessionParameterClientSessionKeepAliveHeartbeatFrequency: + err = setIntegerValue(parameter, value, &sessionParameters.ClientSessionKeepAliveHeartbeatFrequency) + case SessionParameterClientTimestampTypeMapping: + sessionParameters.ClientTimestampTypeMapping = Pointer(ClientTimestampTypeMapping(value)) case SessionParameterDateInputFormat: sessionParameters.DateInputFormat = &value case SessionParameterDateOutputFormat: sessionParameters.DateOutputFormat = &value + case SessionParameterEnableUnloadPhysicalTypeOptimization: + err = setBooleanValue(parameter, value, &sessionParameters.EnableUnloadPhysicalTypeOptimization) case SessionParameterErrorOnNondeterministicMerge: - b, err := parseBooleanParameter(string(parameter), value) - if err != nil { - return err - } - sessionParameters.ErrorOnNondeterministicMerge = b + err = setBooleanValue(parameter, value, &sessionParameters.ErrorOnNondeterministicMerge) case SessionParameterErrorOnNondeterministicUpdate: - b, err := parseBooleanParameter(string(parameter), value) - if err != nil { - return err - } - sessionParameters.ErrorOnNondeterministicUpdate = b + err = setBooleanValue(parameter, value, &sessionParameters.ErrorOnNondeterministicUpdate) case SessionParameterGeographyOutputFormat: sessionParameters.GeographyOutputFormat = Pointer(GeographyOutputFormat(value)) + case SessionParameterGeometryOutputFormat: + sessionParameters.GeometryOutputFormat = Pointer(GeometryOutputFormat(value)) + case SessionParameterJdbcTreatDecimalAsInt: + err = setBooleanValue(parameter, value, &sessionParameters.JdbcTreatDecimalAsInt) + case SessionParameterJdbcTreatTimestampNtzAsUtc: + err = setBooleanValue(parameter, value, &sessionParameters.JdbcTreatTimestampNtzAsUtc) + case SessionParameterJdbcUseSessionTimezone: + err = setBooleanValue(parameter, value, &sessionParameters.JdbcUseSessionTimezone) case SessionParameterJSONIndent: - v, err := strconv.Atoi(value) - if err != nil { - return fmt.Errorf("JSON_INDENT session parameter is an integer, got %v", value) - } - sessionParameters.JSONIndent = Pointer(v) + err = setIntegerValue(parameter, value, &sessionParameters.JSONIndent) case SessionParameterLockTimeout: - v, err := strconv.Atoi(value) - if err != nil { - return fmt.Errorf("LOCK_TIMEOUT session parameter is an integer, got %v", value) - } - sessionParameters.LockTimeout = Pointer(v) + err = setIntegerValue(parameter, value, &sessionParameters.LockTimeout) + case SessionParameterLogLevel: + sessionParameters.LogLevel = Pointer(LogLevel(value)) case SessionParameterMultiStatementCount: - v, err := strconv.Atoi(value) - if err != nil { - return fmt.Errorf("MULTI_STATEMENT_COUNT session parameter is an integer, got %v", value) - } - sessionParameters.MultiStatementCount = Pointer(v) - + err = setIntegerValue(parameter, value, &sessionParameters.MultiStatementCount) + case SessionParameterNoorderSequenceAsDefault: + err = setBooleanValue(parameter, value, &sessionParameters.NoorderSequenceAsDefault) + case SessionParameterOdbcTreatDecimalAsInt: + err = setBooleanValue(parameter, value, &sessionParameters.OdbcTreatDecimalAsInt) case SessionParameterQueryTag: sessionParameters.QueryTag = &value case SessionParameterQuotedIdentifiersIgnoreCase: - b, err := parseBooleanParameter(string(parameter), value) - if err != nil { - return err - } - sessionParameters.QuotedIdentifiersIgnoreCase = b + err = setBooleanValue(parameter, value, &sessionParameters.QuotedIdentifiersIgnoreCase) case SessionParameterRowsPerResultset: - v, err := strconv.Atoi(value) - if err != nil { - return fmt.Errorf("ROWS_PER_RESULTSET session parameter is an integer, got %v", value) - } - sessionParameters.RowsPerResultset = Pointer(v) + err = setIntegerValue(parameter, value, &sessionParameters.RowsPerResultset) case SessionParameterS3StageVpceDnsName: sessionParameters.S3StageVpceDnsName = &value + case SessionParameterSearchPath: + sessionParameters.SearchPath = &value case SessionParameterSimulatedDataSharingConsumer: sessionParameters.SimulatedDataSharingConsumer = &value + case SessionParameterStatementQueuedTimeoutInSeconds: + err = setIntegerValue(parameter, value, &sessionParameters.StatementQueuedTimeoutInSeconds) case SessionParameterStatementTimeoutInSeconds: - v, err := strconv.Atoi(value) - if err != nil { - return fmt.Errorf("STATEMENT_TIMEOUT_IN_SECONDS session parameter is an integer, got %v", value) - } - sessionParameters.StatementTimeoutInSeconds = Pointer(v) + err = setIntegerValue(parameter, value, &sessionParameters.StatementTimeoutInSeconds) case SessionParameterStrictJSONOutput: - b, err := parseBooleanParameter(string(parameter), value) - if err != nil { - return err - } - sessionParameters.StrictJSONOutput = b + err = setBooleanValue(parameter, value, &sessionParameters.StrictJSONOutput) case SessionParameterTimestampDayIsAlways24h: - b, err := parseBooleanParameter(string(parameter), value) - if err != nil { - return err - } - sessionParameters.TimestampDayIsAlways24h = b + err = setBooleanValue(parameter, value, &sessionParameters.TimestampDayIsAlways24h) case SessionParameterTimestampInputFormat: sessionParameters.TimestampInputFormat = &value case SessionParameterTimestampLTZOutputFormat: @@ -138,7 +111,7 @@ func (sessionParameters *SessionParameters) setParam(parameter SessionParameter, case SessionParameterTimestampOutputFormat: sessionParameters.TimestampOutputFormat = &value case SessionParameterTimestampTypeMapping: - sessionParameters.TimestampTypeMapping = &value + sessionParameters.TimestampTypeMapping = Pointer(TimestampTypeMapping(value)) case SessionParameterTimestampTZOutputFormat: sessionParameters.TimestampTZOutputFormat = &value case SessionParameterTimezone: @@ -147,43 +120,43 @@ func (sessionParameters *SessionParameters) setParam(parameter SessionParameter, sessionParameters.TimeInputFormat = &value case SessionParameterTimeOutputFormat: sessionParameters.TimeOutputFormat = &value + case SessionParameterTraceLevel: + sessionParameters.TraceLevel = Pointer(TraceLevel(value)) case SessionParameterTransactionAbortOnError: - b, err := parseBooleanParameter(string(parameter), value) - if err != nil { - return err - } - sessionParameters.TransactionAbortOnError = b + err = setBooleanValue(parameter, value, &sessionParameters.TransactionAbortOnError) case SessionParameterTransactionDefaultIsolationLevel: sessionParameters.TransactionDefaultIsolationLevel = Pointer(TransactionDefaultIsolationLevel(value)) case SessionParameterTwoDigitCenturyStart: - v, err := strconv.Atoi(value) - if err != nil { - return fmt.Errorf("TWO_DIGIT_CENTURY_START session parameter is an integer, got %v", value) - } - sessionParameters.TwoDigitCenturyStart = Pointer(v) + err = setIntegerValue(parameter, value, &sessionParameters.TwoDigitCenturyStart) case SessionParameterUnsupportedDDLAction: sessionParameters.UnsupportedDDLAction = Pointer(UnsupportedDDLAction(value)) case SessionParameterUseCachedResult: - b, err := parseBooleanParameter(string(parameter), value) - if err != nil { - return err - } - sessionParameters.UseCachedResult = b + err = setBooleanValue(parameter, value, &sessionParameters.UseCachedResult) case SessionParameterWeekOfYearPolicy: - v, err := strconv.Atoi(value) - if err != nil { - return fmt.Errorf("WEEK_OF_YEAR_POLICY session parameter is an integer, got %v", value) - } - sessionParameters.WeekOfYearPolicy = Pointer(v) + err = setIntegerValue(parameter, value, &sessionParameters.WeekOfYearPolicy) case SessionParameterWeekStart: - v, err := strconv.Atoi(value) - if err != nil { - return fmt.Errorf("WEEK_START session parameter is an integer, got %v", value) - } - sessionParameters.WeekStart = Pointer(v) + err = setIntegerValue(parameter, value, &sessionParameters.WeekStart) default: - return fmt.Errorf("%s session parameter is not supported", string(parameter)) + err = fmt.Errorf("%s session parameter is not supported", string(parameter)) } + return err +} + +func setBooleanValue(parameter SessionParameter, value string, setField **bool) error { + b, err := parseBooleanParameter(string(parameter), value) + if err != nil { + return err + } + *setField = b + return nil +} + +func setIntegerValue(parameter SessionParameter, value string, setField **int) error { + v, err := strconv.Atoi(value) + if err != nil { + return fmt.Errorf("%s session parameter is an integer, got %v", parameter, value) + } + *setField = Pointer(v) return nil } @@ -199,85 +172,123 @@ func GetSessionParametersUnsetFrom(params map[string]any) (*SessionParametersUns } func (sessionParametersUnset *SessionParametersUnset) setParam(parameter SessionParameter) error { + var unsetField **bool switch parameter { case SessionParameterAbortDetachedQuery: - sessionParametersUnset.AbortDetachedQuery = Bool(true) + unsetField = &sessionParametersUnset.AbortDetachedQuery case SessionParameterAutocommit: - sessionParametersUnset.Autocommit = Bool(true) + unsetField = &sessionParametersUnset.Autocommit case SessionParameterBinaryInputFormat: - sessionParametersUnset.BinaryInputFormat = Bool(true) + unsetField = &sessionParametersUnset.BinaryInputFormat case SessionParameterBinaryOutputFormat: - sessionParametersUnset.BinaryOutputFormat = Bool(true) + unsetField = &sessionParametersUnset.BinaryOutputFormat + case SessionParameterClientMemoryLimit: + unsetField = &sessionParametersUnset.ClientMemoryLimit case SessionParameterClientMetadataRequestUseConnectionCtx: - sessionParametersUnset.ClientMetadataRequestUseConnectionCtx = Bool(true) - case SessionParameterClientMetadataUseSessionDatabase: - sessionParametersUnset.ClientMetadataUseSessionDatabase = Bool(true) + unsetField = &sessionParametersUnset.ClientMetadataRequestUseConnectionCtx + case SessionParameterClientPrefetchThreads: + unsetField = &sessionParametersUnset.ClientPrefetchThreads + case SessionParameterClientResultChunkSize: + unsetField = &sessionParametersUnset.ClientResultChunkSize case SessionParameterClientResultColumnCaseInsensitive: - sessionParametersUnset.ClientResultColumnCaseInsensitive = Bool(true) + unsetField = &sessionParametersUnset.ClientResultColumnCaseInsensitive + case SessionParameterClientMetadataUseSessionDatabase: + unsetField = &sessionParametersUnset.ClientMetadataUseSessionDatabase + case SessionParameterClientSessionKeepAlive: + unsetField = &sessionParametersUnset.ClientSessionKeepAlive + case SessionParameterClientSessionKeepAliveHeartbeatFrequency: + unsetField = &sessionParametersUnset.ClientSessionKeepAliveHeartbeatFrequency + case SessionParameterClientTimestampTypeMapping: + unsetField = &sessionParametersUnset.ClientTimestampTypeMapping case SessionParameterDateInputFormat: - sessionParametersUnset.DateInputFormat = Bool(true) + unsetField = &sessionParametersUnset.DateInputFormat case SessionParameterDateOutputFormat: - sessionParametersUnset.DateOutputFormat = Bool(true) + unsetField = &sessionParametersUnset.DateOutputFormat + case SessionParameterEnableUnloadPhysicalTypeOptimization: + unsetField = &sessionParametersUnset.EnableUnloadPhysicalTypeOptimization case SessionParameterErrorOnNondeterministicMerge: - sessionParametersUnset.ErrorOnNondeterministicMerge = Bool(true) + unsetField = &sessionParametersUnset.ErrorOnNondeterministicMerge case SessionParameterErrorOnNondeterministicUpdate: - sessionParametersUnset.ErrorOnNondeterministicUpdate = Bool(true) + unsetField = &sessionParametersUnset.ErrorOnNondeterministicUpdate case SessionParameterGeographyOutputFormat: - sessionParametersUnset.GeographyOutputFormat = Bool(true) + unsetField = &sessionParametersUnset.GeographyOutputFormat + case SessionParameterGeometryOutputFormat: + unsetField = &sessionParametersUnset.GeometryOutputFormat + case SessionParameterJdbcTreatDecimalAsInt: + unsetField = &sessionParametersUnset.JdbcTreatDecimalAsInt + case SessionParameterJdbcTreatTimestampNtzAsUtc: + unsetField = &sessionParametersUnset.JdbcTreatTimestampNtzAsUtc + case SessionParameterJdbcUseSessionTimezone: + unsetField = &sessionParametersUnset.JdbcUseSessionTimezone case SessionParameterJSONIndent: - sessionParametersUnset.JSONIndent = Bool(true) + unsetField = &sessionParametersUnset.JSONIndent case SessionParameterLockTimeout: - sessionParametersUnset.LockTimeout = Bool(true) + unsetField = &sessionParametersUnset.LockTimeout + case SessionParameterLogLevel: + unsetField = &sessionParametersUnset.LogLevel case SessionParameterMultiStatementCount: - sessionParametersUnset.MultiStatementCount = Bool(true) + unsetField = &sessionParametersUnset.MultiStatementCount + case SessionParameterNoorderSequenceAsDefault: + unsetField = &sessionParametersUnset.NoorderSequenceAsDefault + case SessionParameterOdbcTreatDecimalAsInt: + unsetField = &sessionParametersUnset.OdbcTreatDecimalAsInt case SessionParameterQueryTag: - sessionParametersUnset.QueryTag = Bool(true) + unsetField = &sessionParametersUnset.QueryTag case SessionParameterQuotedIdentifiersIgnoreCase: - sessionParametersUnset.QuotedIdentifiersIgnoreCase = Bool(true) + unsetField = &sessionParametersUnset.QuotedIdentifiersIgnoreCase case SessionParameterRowsPerResultset: - sessionParametersUnset.RowsPerResultset = Bool(true) + unsetField = &sessionParametersUnset.RowsPerResultset case SessionParameterS3StageVpceDnsName: - sessionParametersUnset.S3StageVpceDnsName = Bool(true) + unsetField = &sessionParametersUnset.S3StageVpceDnsName + case SessionParameterSearchPath: + unsetField = &sessionParametersUnset.SearchPath case SessionParameterSimulatedDataSharingConsumer: - sessionParametersUnset.SimulatedDataSharingConsumer = Bool(true) + unsetField = &sessionParametersUnset.SimulatedDataSharingConsumer + case SessionParameterStatementQueuedTimeoutInSeconds: + unsetField = &sessionParametersUnset.StatementQueuedTimeoutInSeconds case SessionParameterStatementTimeoutInSeconds: - sessionParametersUnset.StatementTimeoutInSeconds = Bool(true) + unsetField = &sessionParametersUnset.StatementTimeoutInSeconds case SessionParameterStrictJSONOutput: - sessionParametersUnset.StrictJSONOutput = Bool(true) + unsetField = &sessionParametersUnset.StrictJSONOutput case SessionParameterTimestampDayIsAlways24h: - sessionParametersUnset.TimestampDayIsAlways24h = Bool(true) + unsetField = &sessionParametersUnset.TimestampDayIsAlways24h case SessionParameterTimestampInputFormat: - sessionParametersUnset.TimestampInputFormat = Bool(true) + unsetField = &sessionParametersUnset.TimestampInputFormat case SessionParameterTimestampLTZOutputFormat: - sessionParametersUnset.TimestampLTZOutputFormat = Bool(true) + unsetField = &sessionParametersUnset.TimestampLTZOutputFormat case SessionParameterTimestampNTZOutputFormat: - sessionParametersUnset.TimestampNTZOutputFormat = Bool(true) + unsetField = &sessionParametersUnset.TimestampNTZOutputFormat case SessionParameterTimestampOutputFormat: - sessionParametersUnset.TimestampOutputFormat = Bool(true) + unsetField = &sessionParametersUnset.TimestampOutputFormat case SessionParameterTimestampTypeMapping: - sessionParametersUnset.TimestampTypeMapping = Bool(true) + unsetField = &sessionParametersUnset.TimestampTypeMapping case SessionParameterTimestampTZOutputFormat: - sessionParametersUnset.TimestampTZOutputFormat = Bool(true) + unsetField = &sessionParametersUnset.TimestampTZOutputFormat case SessionParameterTimezone: - sessionParametersUnset.Timezone = Bool(true) + unsetField = &sessionParametersUnset.Timezone case SessionParameterTimeInputFormat: - sessionParametersUnset.TimeInputFormat = Bool(true) + unsetField = &sessionParametersUnset.TimeInputFormat case SessionParameterTimeOutputFormat: - sessionParametersUnset.TimeOutputFormat = Bool(true) + unsetField = &sessionParametersUnset.TimeOutputFormat + case SessionParameterTraceLevel: + unsetField = &sessionParametersUnset.TraceLevel + case SessionParameterTransactionAbortOnError: + unsetField = &sessionParametersUnset.TransactionAbortOnError case SessionParameterTransactionDefaultIsolationLevel: - sessionParametersUnset.TransactionDefaultIsolationLevel = Bool(true) + unsetField = &sessionParametersUnset.TransactionDefaultIsolationLevel case SessionParameterTwoDigitCenturyStart: - sessionParametersUnset.TwoDigitCenturyStart = Bool(true) + unsetField = &sessionParametersUnset.TwoDigitCenturyStart case SessionParameterUnsupportedDDLAction: - sessionParametersUnset.UnsupportedDDLAction = Bool(true) + unsetField = &sessionParametersUnset.UnsupportedDDLAction case SessionParameterUseCachedResult: - sessionParametersUnset.UseCachedResult = Bool(true) + unsetField = &sessionParametersUnset.UseCachedResult case SessionParameterWeekOfYearPolicy: - sessionParametersUnset.WeekOfYearPolicy = Bool(true) + unsetField = &sessionParametersUnset.WeekOfYearPolicy case SessionParameterWeekStart: - sessionParametersUnset.WeekStart = Bool(true) + unsetField = &sessionParametersUnset.WeekStart default: return fmt.Errorf("%s session parameter is not supported", string(parameter)) } + *unsetField = Bool(true) return nil } diff --git a/pkg/sdk/parameters_impl_test.go b/pkg/sdk/parameters_impl_test.go index 1a46d2ec2f..d235a42a5e 100644 --- a/pkg/sdk/parameters_impl_test.go +++ b/pkg/sdk/parameters_impl_test.go @@ -18,34 +18,52 @@ func TestSessionParameters_setParam(t *testing.T) { {parameter: SessionParameterAutocommit, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.Autocommit }}, {parameter: SessionParameterBinaryInputFormat, value: "some", expectedValue: BinaryInputFormat("some"), accessor: func(sp *SessionParameters) any { return *sp.BinaryInputFormat }}, {parameter: SessionParameterBinaryOutputFormat, value: "some", expectedValue: BinaryOutputFormat("some"), accessor: func(sp *SessionParameters) any { return *sp.BinaryOutputFormat }}, + {parameter: SessionParameterClientMemoryLimit, value: "1", expectedValue: 1, accessor: func(sp *SessionParameters) any { return *sp.ClientMemoryLimit }}, {parameter: SessionParameterClientMetadataRequestUseConnectionCtx, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.ClientMetadataRequestUseConnectionCtx }}, - {parameter: SessionParameterClientMetadataUseSessionDatabase, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.ClientMetadataUseSessionDatabase }}, + {parameter: SessionParameterClientPrefetchThreads, value: "1", expectedValue: 1, accessor: func(sp *SessionParameters) any { return *sp.ClientPrefetchThreads }}, + {parameter: SessionParameterClientResultChunkSize, value: "1", expectedValue: 1, accessor: func(sp *SessionParameters) any { return *sp.ClientResultChunkSize }}, {parameter: SessionParameterClientResultColumnCaseInsensitive, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.ClientResultColumnCaseInsensitive }}, + {parameter: SessionParameterClientMetadataUseSessionDatabase, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.ClientMetadataUseSessionDatabase }}, + {parameter: SessionParameterClientSessionKeepAlive, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.ClientSessionKeepAlive }}, + {parameter: SessionParameterClientSessionKeepAliveHeartbeatFrequency, value: "1", expectedValue: 1, accessor: func(sp *SessionParameters) any { return *sp.ClientSessionKeepAliveHeartbeatFrequency }}, + {parameter: SessionParameterClientTimestampTypeMapping, value: "some", expectedValue: ClientTimestampTypeMapping("some"), accessor: func(sp *SessionParameters) any { return *sp.ClientTimestampTypeMapping }}, {parameter: SessionParameterDateInputFormat, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.DateInputFormat }}, - {parameter: SessionParameterGeographyOutputFormat, value: "some", expectedValue: GeographyOutputFormat("some"), accessor: func(sp *SessionParameters) any { return *sp.GeographyOutputFormat }}, {parameter: SessionParameterDateOutputFormat, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.DateOutputFormat }}, + {parameter: SessionParameterEnableUnloadPhysicalTypeOptimization, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.EnableUnloadPhysicalTypeOptimization }}, {parameter: SessionParameterErrorOnNondeterministicMerge, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.ErrorOnNondeterministicMerge }}, {parameter: SessionParameterErrorOnNondeterministicUpdate, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.ErrorOnNondeterministicUpdate }}, + {parameter: SessionParameterGeographyOutputFormat, value: "some", expectedValue: GeographyOutputFormat("some"), accessor: func(sp *SessionParameters) any { return *sp.GeographyOutputFormat }}, + {parameter: SessionParameterGeometryOutputFormat, value: "some", expectedValue: GeometryOutputFormat("some"), accessor: func(sp *SessionParameters) any { return *sp.GeometryOutputFormat }}, + {parameter: SessionParameterJdbcTreatDecimalAsInt, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.JdbcTreatDecimalAsInt }}, + {parameter: SessionParameterJdbcTreatTimestampNtzAsUtc, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.JdbcTreatTimestampNtzAsUtc }}, + {parameter: SessionParameterJdbcUseSessionTimezone, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.JdbcUseSessionTimezone }}, {parameter: SessionParameterJSONIndent, value: "1", expectedValue: 1, accessor: func(sp *SessionParameters) any { return *sp.JSONIndent }}, {parameter: SessionParameterLockTimeout, value: "1", expectedValue: 1, accessor: func(sp *SessionParameters) any { return *sp.LockTimeout }}, + {parameter: SessionParameterLogLevel, value: "some", expectedValue: LogLevel("some"), accessor: func(sp *SessionParameters) any { return *sp.LogLevel }}, {parameter: SessionParameterMultiStatementCount, value: "1", expectedValue: 1, accessor: func(sp *SessionParameters) any { return *sp.MultiStatementCount }}, + {parameter: SessionParameterNoorderSequenceAsDefault, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.NoorderSequenceAsDefault }}, + {parameter: SessionParameterOdbcTreatDecimalAsInt, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.OdbcTreatDecimalAsInt }}, {parameter: SessionParameterQueryTag, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.QueryTag }}, {parameter: SessionParameterQuotedIdentifiersIgnoreCase, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.QuotedIdentifiersIgnoreCase }}, {parameter: SessionParameterRowsPerResultset, value: "1", expectedValue: 1, accessor: func(sp *SessionParameters) any { return *sp.RowsPerResultset }}, {parameter: SessionParameterS3StageVpceDnsName, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.S3StageVpceDnsName }}, + {parameter: SessionParameterSearchPath, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.SearchPath }}, {parameter: SessionParameterSimulatedDataSharingConsumer, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.SimulatedDataSharingConsumer }}, + {parameter: SessionParameterStatementQueuedTimeoutInSeconds, value: "1", expectedValue: 1, accessor: func(sp *SessionParameters) any { return *sp.StatementQueuedTimeoutInSeconds }}, {parameter: SessionParameterStatementTimeoutInSeconds, value: "1", expectedValue: 1, accessor: func(sp *SessionParameters) any { return *sp.StatementTimeoutInSeconds }}, {parameter: SessionParameterStrictJSONOutput, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.StrictJSONOutput }}, - {parameter: SessionParameterTimeInputFormat, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.TimeInputFormat }}, - {parameter: SessionParameterTimeOutputFormat, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.TimeOutputFormat }}, {parameter: SessionParameterTimestampDayIsAlways24h, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.TimestampDayIsAlways24h }}, {parameter: SessionParameterTimestampInputFormat, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.TimestampInputFormat }}, {parameter: SessionParameterTimestampLTZOutputFormat, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.TimestampLTZOutputFormat }}, {parameter: SessionParameterTimestampNTZOutputFormat, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.TimestampNTZOutputFormat }}, {parameter: SessionParameterTimestampOutputFormat, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.TimestampOutputFormat }}, - {parameter: SessionParameterTimestampTypeMapping, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.TimestampTypeMapping }}, + {parameter: SessionParameterTimestampTypeMapping, value: "some", expectedValue: TimestampTypeMapping("some"), accessor: func(sp *SessionParameters) any { return *sp.TimestampTypeMapping }}, {parameter: SessionParameterTimestampTZOutputFormat, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.TimestampTZOutputFormat }}, {parameter: SessionParameterTimezone, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.Timezone }}, + {parameter: SessionParameterTimeInputFormat, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.TimeInputFormat }}, + {parameter: SessionParameterTimeOutputFormat, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.TimeOutputFormat }}, + {parameter: SessionParameterTraceLevel, value: "some", expectedValue: TraceLevel("some"), accessor: func(sp *SessionParameters) any { return *sp.TraceLevel }}, + {parameter: SessionParameterTransactionAbortOnError, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.TransactionAbortOnError }}, {parameter: SessionParameterTransactionDefaultIsolationLevel, value: "some", expectedValue: TransactionDefaultIsolationLevel("some"), accessor: func(sp *SessionParameters) any { return *sp.TransactionDefaultIsolationLevel }}, {parameter: SessionParameterTwoDigitCenturyStart, value: "1", expectedValue: 1, accessor: func(sp *SessionParameters) any { return *sp.TwoDigitCenturyStart }}, {parameter: SessionParameterUnsupportedDDLAction, value: "some", expectedValue: UnsupportedDDLAction("some"), accessor: func(sp *SessionParameters) any { return *sp.UnsupportedDDLAction }}, From 7e27aaef906fa176c592131aef14f3002cf7469f Mon Sep 17 00:00:00 2001 From: Artur Sawicki Date: Fri, 12 Jul 2024 15:28:37 +0200 Subject: [PATCH 3/4] Fix make pre-push --- pkg/sdk/testint/conversion_functions_integration_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/sdk/testint/conversion_functions_integration_test.go b/pkg/sdk/testint/conversion_functions_integration_test.go index b9b37441e8..b04c25efb7 100644 --- a/pkg/sdk/testint/conversion_functions_integration_test.go +++ b/pkg/sdk/testint/conversion_functions_integration_test.go @@ -16,7 +16,7 @@ func TestInt_ToTimestampLTZ(t *testing.T) { Set: &sdk.AccountSet{ Parameters: &sdk.AccountLevelParameters{ SessionParameters: &sdk.SessionParameters{ - TimestampTypeMapping: sdk.String("TIMESTAMP_LTZ"), + TimestampTypeMapping: sdk.Pointer(sdk.TimestampTypeMappingLtz), Timezone: sdk.String("UTC"), }, }, @@ -55,7 +55,7 @@ func TestInt_ToTimestampNTZ(t *testing.T) { Set: &sdk.AccountSet{ Parameters: &sdk.AccountLevelParameters{ SessionParameters: &sdk.SessionParameters{ - TimestampTypeMapping: sdk.String("TIMESTAMP_NTZ"), + TimestampTypeMapping: sdk.Pointer(sdk.TimestampTypeMappingLtz), Timezone: sdk.String("UTC"), }, }, From 6b6bd4575d24f23782b27016d70cb923c3cb847c Mon Sep 17 00:00:00 2001 From: Artur Sawicki Date: Fri, 12 Jul 2024 17:01:08 +0200 Subject: [PATCH 4/4] Fix after the review --- pkg/sdk/parameters_impl.go | 1 + pkg/sdk/tasks_gen_test.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/sdk/parameters_impl.go b/pkg/sdk/parameters_impl.go index c36e4ce946..098e9e1d03 100644 --- a/pkg/sdk/parameters_impl.go +++ b/pkg/sdk/parameters_impl.go @@ -21,6 +21,7 @@ func GetSessionParametersFrom(params map[string]any) (*SessionParameters, error) } // TODO [SNOW-1348330]: get type based on the tag in SessionParameters struct and handle in a generic way +// TODO [SNOW-1348330]: use sdk.ToX for the enums func (sessionParameters *SessionParameters) setParam(parameter SessionParameter, value string) error { var err error switch parameter { diff --git a/pkg/sdk/tasks_gen_test.go b/pkg/sdk/tasks_gen_test.go index 0278e1803b..926958427e 100644 --- a/pkg/sdk/tasks_gen_test.go +++ b/pkg/sdk/tasks_gen_test.go @@ -200,7 +200,7 @@ func TestTasks_Alter(t *testing.T) { opts := defaultOpts() opts.Unset = &TaskUnset{} opts.Unset.SessionParametersUnset = &SessionParametersUnset{} - assertOptsInvalidJoinedErrors(t, opts, errAtLeastOneOf("SessionParametersUnset", "AbortDetachedQuery", "Autocommit", "BinaryInputFormat", "BinaryOutputFormat", "DateInputFormat", "DateOutputFormat", "ErrorOnNondeterministicMerge", "ErrorOnNondeterministicUpdate", "GeographyOutputFormat", "JSONIndent", "LockTimeout", "QueryTag", "RowsPerResultset", "SimulatedDataSharingConsumer", "StatementTimeoutInSeconds", "StrictJSONOutput", "TimestampDayIsAlways24h", "TimestampInputFormat", "TimestampLTZOutputFormat", "TimestampNTZOutputFormat", "TimestampOutputFormat", "TimestampTypeMapping", "TimestampTZOutputFormat", "Timezone", "TimeInputFormat", "TimeOutputFormat", "TransactionDefaultIsolationLevel", "TwoDigitCenturyStart", "UnsupportedDDLAction", "UseCachedResult", "WeekOfYearPolicy", "WeekStart")) + assertOptsInvalidJoinedErrors(t, opts, errAtLeastOneOf("SessionParametersUnset", "AbortDetachedQuery", "Autocommit", "BinaryInputFormat", "BinaryOutputFormat", "ClientMemoryLimit", "ClientMetadataRequestUseConnectionCtx", "ClientPrefetchThreads", "ClientResultChunkSize", "ClientResultColumnCaseInsensitive", "ClientMetadataUseSessionDatabase", "ClientSessionKeepAlive", "ClientSessionKeepAliveHeartbeatFrequency", "ClientTimestampTypeMapping", "DateInputFormat", "DateOutputFormat", "EnableUnloadPhysicalTypeOptimization", "ErrorOnNondeterministicMerge", "ErrorOnNondeterministicUpdate", "GeographyOutputFormat", "GeometryOutputFormat", "JdbcTreatDecimalAsInt", "JdbcTreatTimestampNtzAsUtc", "JdbcUseSessionTimezone", "JSONIndent", "LockTimeout", "LogLevel", "MultiStatementCount", "NoorderSequenceAsDefault", "OdbcTreatDecimalAsInt", "QueryTag", "QuotedIdentifiersIgnoreCase", "RowsPerResultset", "S3StageVpceDnsName", "SearchPath", "SimulatedDataSharingConsumer", "StatementQueuedTimeoutInSeconds", "StatementTimeoutInSeconds", "StrictJSONOutput", "TimestampDayIsAlways24h", "TimestampInputFormat", "TimestampLTZOutputFormat", "TimestampNTZOutputFormat", "TimestampOutputFormat", "TimestampTypeMapping", "TimestampTZOutputFormat", "Timezone", "TimeInputFormat", "TimeOutputFormat", "TraceLevel", "TransactionAbortOnError", "TransactionDefaultIsolationLevel", "TwoDigitCenturyStart", "UnsupportedDDLAction", "UseCachedResult", "WeekOfYearPolicy", "WeekStart")) }) t.Run("alter resume", func(t *testing.T) {