From f5462d5741a7c157271cce8c0e4084e8d7f588e9 Mon Sep 17 00:00:00 2001 From: Jakub Michalak Date: Fri, 20 Dec 2024 14:57:07 +0100 Subject: [PATCH] fix: Fixes in account parameters (#3310) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add missing parameters based on the docs and output of SHOW PARAMETERS IN ACCOUNT - Add missing unit tests and implementations - Add missing validations - Relax validations for ints - just validate if they are non-negative - Update docs ## Test Plan * [ ] acceptance tests * [ ] … ## References #3044 #3116 #3245 ## TODO - Do not add missing user parameters - this will be done in SNOW-1844996. Here, they are added only to account and session level - More acceptance and integration tests should be done on a separate account. This should be done during account resource follow-up (SNOW-1866453) --- MIGRATION_GUIDE.md | 45 +++ docs/resources/account_parameter.md | 2 +- pkg/resources/account_parameter.go | 2 +- .../account_parameter_acceptance_test.go | 44 ++- pkg/resources/task_parameters.go | 8 +- pkg/resources/user_parameters.go | 8 +- pkg/sdk/accounts_test.go | 2 +- pkg/sdk/parameters.go | 334 +++++++++++++----- pkg/sdk/parameters_impl.go | 44 ++- pkg/sdk/parameters_impl_test.go | 15 +- pkg/sdk/parameters_test.go | 39 +- pkg/sdk/tags_validations.go | 2 +- pkg/sdk/tasks_gen_test.go | 14 +- pkg/sdk/testint/accounts_integration_test.go | 10 +- pkg/sdk/testint/tasks_gen_integration_test.go | 10 +- pkg/sdk/testint/users_integration_test.go | 16 +- pkg/sdk/validations.go | 2 +- pkg/sdk/validations_test.go | 6 +- pkg/sdk/warehouses.go | 6 +- 19 files changed, 458 insertions(+), 151 deletions(-) diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index 3ecf522a66..005f3992ed 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -7,6 +7,51 @@ across different versions. > [!TIP] > We highly recommend upgrading the versions one by one instead of bulk upgrades. +## v1.0.0 ➞ v1.0.1 + +### Fixes in account parameters +As a follow-up of reworked `snowflake_account_parameter`, this version has several improvements regarding handling parameters. + +#### Add missing parameters based on the docs and output of SHOW PARAMETERS IN ACCOUNT +Based on [parameters docs](https://docs.snowflake.com/en/sql-reference/parameters) and `SHOW PARAMETERS IN ACCOUNT`, we established a list of supported parameters. New supported or fixed parameters in `snowflake_account_parameter`: +- `ACTIVE_PYTHON_PROFILER` +- `CLIENT_ENABLE_LOG_INFO_STATEMENT_PARAMETERS` +- `CORTEX_ENABLED_CROSS_REGION` +- `CSV_TIMESTAMP_FORMAT` +- `ENABLE_PERSONAL_DATABASE` +- `ENABLE_UNHANDLED_EXCEPTIONS_REPORTING` +- `ENFORCE_NETWORK_RULES_FOR_INTERNAL_STAGES` +- `HYBRID_TABLE_LOCK_TIMEOUT` +- `JS_TREAT_INTEGER_AS_BIGINT` +- `PREVENT_UNLOAD_TO_INLINE_URL` +- `PREVENT_UNLOAD_TO_INTERNAL_STAGES` +- `PYTHON_PROFILER_MODULES` +- `PYTHON_PROFILER_TARGET_STAGE` +- `STORAGE_SERIALIZATION_POLICY` +- `TASK_AUTO_RETRY_ATTEMPTS` + +#### Adjusted validations +Validations for number parameters are now relaxed. This is because a few of the value limits are soft limits in Snowflake, and can be changed externally. +We decided to keep validations for non-negative values. Affected parameters: +- `QUERY_TAG` +- `TWO_DIGIT_CENTURY_START` +- `WEEK_OF_YEAR_POLICY` +- `WEEK_START` +- `USER_TASK_TIMEOUT_MS` + +We added non-negative validations for the following parameters: +- `CLIENT_PREFETCH_THREADS` +- `CLIENT_RESULT_CHUNK_SIZE` +- `CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY` +- `HYBRID_TABLE_LOCK_TIMEOUT` +- `JSON_INDENT` +- `STATEMENT_QUEUED_TIMEOUT_IN_SECONDS` +- `STATEMENT_TIMEOUT_IN_SECONDS` +- `TASK_AUTO_RETRY_ATTEMPTS` +- `USER_TASK_MINIMUM_TRIGGER_INTERVAL_IN_SECONDS` + +Note that enum parameters are still not validated by the provider - they are only validated in Snowflake. We will handle this during a small rework of the parameters in the future. + ## v0.100.0 ➞ v1.0.0 ### Preview features flag diff --git a/docs/resources/account_parameter.md b/docs/resources/account_parameter.md index 07b49e485f..c5fee04863 100644 --- a/docs/resources/account_parameter.md +++ b/docs/resources/account_parameter.md @@ -34,7 +34,7 @@ resource "snowflake_account_parameter" "p2" { ### Required -- `key` (String) Name of account parameter. Valid values are (case-insensitive): `ALLOW_CLIENT_MFA_CACHING` | `ALLOW_ID_TOKEN` | `CLIENT_ENCRYPTION_KEY_SIZE` | `ENABLE_IDENTIFIER_FIRST_LOGIN` | `ENABLE_INTERNAL_STAGES_PRIVATELINK` | `ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_IMAGE_REPOSITORY` | `ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_SPCS_BLOCK_STORAGE` | `EVENT_TABLE` | `EXTERNAL_OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST` | `INITIAL_REPLICATION_SIZE_LIMIT_IN_TB` | `MIN_DATA_RETENTION_TIME_IN_DAYS` | `NETWORK_POLICY` | `OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST` | `PERIODIC_DATA_REKEYING` | `PREVENT_LOAD_FROM_INLINE_URL` | `PREVENT_UNLOAD_TO_INLINE_URL` | `PREVENT_UNLOAD_TO_INTERNAL_STAGES` | `REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION` | `REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_OPERATION` | `SSO_LOGIN_PAGE` | `ABORT_DETACHED_QUERY` | `AUTOCOMMIT` | `BINARY_INPUT_FORMAT` | `BINARY_OUTPUT_FORMAT` | `CLIENT_MEMORY_LIMIT` | `CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX` | `CLIENT_METADATA_USE_SESSION_DATABASE` | `CLIENT_PREFETCH_THREADS` | `CLIENT_RESULT_CHUNK_SIZE` | `CLIENT_SESSION_KEEP_ALIVE` | `CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY` | `CLIENT_TIMESTAMP_TYPE_MAPPING` | `ENABLE_UNLOAD_PHYSICAL_TYPE_OPTIMIZATION` | `CLIENT_RESULT_COLUMN_CASE_INSENSITIVE` | `DATE_INPUT_FORMAT` | `DATE_OUTPUT_FORMAT` | `ERROR_ON_NONDETERMINISTIC_MERGE` | `ERROR_ON_NONDETERMINISTIC_UPDATE` | `GEOGRAPHY_OUTPUT_FORMAT` | `GEOMETRY_OUTPUT_FORMAT` | `JDBC_TREAT_DECIMAL_AS_INT` | `JDBC_TREAT_TIMESTAMP_NTZ_AS_UTC` | `JDBC_USE_SESSION_TIMEZONE` | `JSON_INDENT` | `LOCK_TIMEOUT` | `MULTI_STATEMENT_COUNT` | `NOORDER_SEQUENCE_AS_DEFAULT` | `ODBC_TREAT_DECIMAL_AS_INT` | `QUERY_TAG` | `QUOTED_IDENTIFIERS_IGNORE_CASE` | `ROWS_PER_RESULTSET` | `S3_STAGE_VPCE_DNS_NAME` | `SEARCH_PATH` | `SIMULATED_DATA_SHARING_CONSUMER` | `STATEMENT_TIMEOUT_IN_SECONDS` | `STRICT_JSON_OUTPUT` | `TIME_INPUT_FORMAT` | `TIME_OUTPUT_FORMAT` | `TIMESTAMP_DAY_IS_ALWAYS_24H` | `TIMESTAMP_INPUT_FORMAT` | `TIMESTAMP_LTZ_OUTPUT_FORMAT` | `TIMESTAMP_NTZ_OUTPUT_FORMAT` | `TIMESTAMP_OUTPUT_FORMAT` | `TIMESTAMP_TYPE_MAPPING` | `TIMESTAMP_TZ_OUTPUT_FORMAT` | `TIMEZONE` | `TRANSACTION_ABORT_ON_ERROR` | `TRANSACTION_DEFAULT_ISOLATION_LEVEL` | `TWO_DIGIT_CENTURY_START` | `UNSUPPORTED_DDL_ACTION` | `USE_CACHED_RESULT` | `WEEK_OF_YEAR_POLICY` | `WEEK_START` | `CATALOG` | `DATA_RETENTION_TIME_IN_DAYS` | `DEFAULT_DDL_COLLATION` | `EXTERNAL_VOLUME` | `LOG_LEVEL` | `MAX_CONCURRENCY_LEVEL` | `MAX_DATA_EXTENSION_TIME_IN_DAYS` | `PIPE_EXECUTION_PAUSED` | `PREVENT_UNLOAD_TO_INTERNAL_STAGES` | `REPLACE_INVALID_CHARACTERS` | `STATEMENT_QUEUED_TIMEOUT_IN_SECONDS` | `STORAGE_SERIALIZATION_POLICY` | `SHARE_RESTRICTIONS` | `SUSPEND_TASK_AFTER_NUM_FAILURES` | `TRACE_LEVEL` | `USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE` | `USER_TASK_TIMEOUT_MS` | `TASK_AUTO_RETRY_ATTEMPTS` | `USER_TASK_MINIMUM_TRIGGER_INTERVAL_IN_SECONDS` | `METRIC_LEVEL` | `ENABLE_CONSOLE_OUTPUT` | `ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR`. +- `key` (String) Name of account parameter. Valid values are (case-insensitive): `ALLOW_CLIENT_MFA_CACHING` | `ALLOW_ID_TOKEN` | `CLIENT_ENCRYPTION_KEY_SIZE` | `CORTEX_ENABLED_CROSS_REGION` | `ENABLE_IDENTIFIER_FIRST_LOGIN` | `ENABLE_INTERNAL_STAGES_PRIVATELINK` | `ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_IMAGE_REPOSITORY` | `ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_SPCS_BLOCK_STORAGE` | `ENABLE_UNHANDLED_EXCEPTIONS_REPORTING` | `ENFORCE_NETWORK_RULES_FOR_INTERNAL_STAGES` | `EVENT_TABLE` | `EXTERNAL_OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST` | `INITIAL_REPLICATION_SIZE_LIMIT_IN_TB` | `MIN_DATA_RETENTION_TIME_IN_DAYS` | `NETWORK_POLICY` | `OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST` | `PERIODIC_DATA_REKEYING` | `PREVENT_LOAD_FROM_INLINE_URL` | `PREVENT_UNLOAD_TO_INLINE_URL` | `REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION` | `REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_OPERATION` | `SSO_LOGIN_PAGE` | `ABORT_DETACHED_QUERY` | `ACTIVE_PYTHON_PROFILER` | `AUTOCOMMIT` | `BINARY_INPUT_FORMAT` | `BINARY_OUTPUT_FORMAT` | `CLIENT_ENABLE_LOG_INFO_STATEMENT_PARAMETERS` | `CLIENT_MEMORY_LIMIT` | `CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX` | `CLIENT_METADATA_USE_SESSION_DATABASE` | `CLIENT_PREFETCH_THREADS` | `CLIENT_RESULT_CHUNK_SIZE` | `CLIENT_SESSION_KEEP_ALIVE` | `CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY` | `CLIENT_TIMESTAMP_TYPE_MAPPING` | `ENABLE_UNLOAD_PHYSICAL_TYPE_OPTIMIZATION` | `CLIENT_RESULT_COLUMN_CASE_INSENSITIVE` | `CSV_TIMESTAMP_FORMAT` | `DATE_INPUT_FORMAT` | `DATE_OUTPUT_FORMAT` | `ERROR_ON_NONDETERMINISTIC_MERGE` | `ERROR_ON_NONDETERMINISTIC_UPDATE` | `GEOGRAPHY_OUTPUT_FORMAT` | `GEOMETRY_OUTPUT_FORMAT` | `HYBRID_TABLE_LOCK_TIMEOUT` | `JDBC_TREAT_DECIMAL_AS_INT` | `JDBC_TREAT_TIMESTAMP_NTZ_AS_UTC` | `JDBC_USE_SESSION_TIMEZONE` | `JSON_INDENT` | `JS_TREAT_INTEGER_AS_BIGINT` | `LOCK_TIMEOUT` | `MULTI_STATEMENT_COUNT` | `NOORDER_SEQUENCE_AS_DEFAULT` | `ODBC_TREAT_DECIMAL_AS_INT` | `PYTHON_PROFILER_MODULES` | `PYTHON_PROFILER_TARGET_STAGE` | `QUERY_TAG` | `QUOTED_IDENTIFIERS_IGNORE_CASE` | `ROWS_PER_RESULTSET` | `S3_STAGE_VPCE_DNS_NAME` | `SEARCH_PATH` | `SIMULATED_DATA_SHARING_CONSUMER` | `STATEMENT_TIMEOUT_IN_SECONDS` | `STRICT_JSON_OUTPUT` | `TIME_INPUT_FORMAT` | `TIME_OUTPUT_FORMAT` | `TIMESTAMP_DAY_IS_ALWAYS_24H` | `TIMESTAMP_INPUT_FORMAT` | `TIMESTAMP_LTZ_OUTPUT_FORMAT` | `TIMESTAMP_NTZ_OUTPUT_FORMAT` | `TIMESTAMP_OUTPUT_FORMAT` | `TIMESTAMP_TYPE_MAPPING` | `TIMESTAMP_TZ_OUTPUT_FORMAT` | `TIMEZONE` | `TRANSACTION_ABORT_ON_ERROR` | `TRANSACTION_DEFAULT_ISOLATION_LEVEL` | `TWO_DIGIT_CENTURY_START` | `UNSUPPORTED_DDL_ACTION` | `USE_CACHED_RESULT` | `WEEK_OF_YEAR_POLICY` | `WEEK_START` | `CATALOG` | `DATA_RETENTION_TIME_IN_DAYS` | `DEFAULT_DDL_COLLATION` | `EXTERNAL_VOLUME` | `LOG_LEVEL` | `MAX_CONCURRENCY_LEVEL` | `MAX_DATA_EXTENSION_TIME_IN_DAYS` | `PIPE_EXECUTION_PAUSED` | `PREVENT_UNLOAD_TO_INTERNAL_STAGES` | `REPLACE_INVALID_CHARACTERS` | `STATEMENT_QUEUED_TIMEOUT_IN_SECONDS` | `STORAGE_SERIALIZATION_POLICY` | `SHARE_RESTRICTIONS` | `SUSPEND_TASK_AFTER_NUM_FAILURES` | `TRACE_LEVEL` | `USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE` | `USER_TASK_TIMEOUT_MS` | `TASK_AUTO_RETRY_ATTEMPTS` | `USER_TASK_MINIMUM_TRIGGER_INTERVAL_IN_SECONDS` | `METRIC_LEVEL` | `ENABLE_CONSOLE_OUTPUT` | `ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR` | `ENABLE_PERSONAL_DATABASE`. Deprecated parameters are not supported in the provider. - `value` (String) Value of account parameter, as a string. Constraints are the same as those for the parameters in Snowflake documentation. The parameter values are validated in Snowflake. ### Read-Only diff --git a/pkg/resources/account_parameter.go b/pkg/resources/account_parameter.go index 2f8021c080..ca10e4a209 100644 --- a/pkg/resources/account_parameter.go +++ b/pkg/resources/account_parameter.go @@ -22,7 +22,7 @@ var accountParameterSchema = map[string]*schema.Schema{ ForceNew: true, ValidateDiagFunc: sdkValidation(sdk.ToAccountParameter), DiffSuppressFunc: NormalizeAndCompare(sdk.ToAccountParameter), - Description: fmt.Sprintf("Name of account parameter. Valid values are (case-insensitive): %s.", possibleValuesListed(sdk.AsStringList(sdk.AllAccountParameters))), + Description: fmt.Sprintf("Name of account parameter. Valid values are (case-insensitive): %s. Deprecated parameters are not supported in the provider.", possibleValuesListed(sdk.AsStringList(sdk.AllAccountParameters))), }, "value": { Type: schema.TypeString, diff --git a/pkg/resources/account_parameter_acceptance_test.go b/pkg/resources/account_parameter_acceptance_test.go index 621b8103a9..6ee2edb147 100644 --- a/pkg/resources/account_parameter_acceptance_test.go +++ b/pkg/resources/account_parameter_acceptance_test.go @@ -131,4 +131,46 @@ func TestAcc_AccountParameter_Issue3025(t *testing.T) { }) } -// TODO(next pr): add more acc tests for the remaining parameters +func TestAcc_AccountParameter_ENFORCE_NETWORK_RULES_FOR_INTERNAL_STAGES(t *testing.T) { + model := model.AccountParameter("test", string(sdk.AccountParameterRequireStorageIntegrationForStageCreation), "true") + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories, + PreCheck: func() { acc.TestAccPreCheck(t) }, + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.RequireAbove(tfversion.Version1_5_0), + }, + CheckDestroy: acc.CheckAccountParameterUnset(t, sdk.AccountParameterRequireStorageIntegrationForStageCreation), + Steps: []resource.TestStep{ + { + Config: config.FromModel(t, model), + Check: assert.AssertThat(t, resourceassert.AccountParameterResource(t, model.ResourceReference()). + HasKeyString(string(sdk.AccountParameterRequireStorageIntegrationForStageCreation)). + HasValueString("true"), + ), + }, + }, + }) +} + +func TestAcc_AccountParameter_INITIAL_REPLICATION_SIZE_LIMIT_IN_TB(t *testing.T) { + model := model.AccountParameter("test", string(sdk.AccountParameterInitialReplicationSizeLimitInTB), "3.0") + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories, + PreCheck: func() { acc.TestAccPreCheck(t) }, + TerraformVersionChecks: []tfversion.TerraformVersionCheck{ + tfversion.RequireAbove(tfversion.Version1_5_0), + }, + CheckDestroy: acc.CheckAccountParameterUnset(t, sdk.AccountParameterInitialReplicationSizeLimitInTB), + Steps: []resource.TestStep{ + { + Config: config.FromModel(t, model), + Check: assert.AssertThat(t, resourceassert.AccountParameterResource(t, model.ResourceReference()). + HasKeyString(string(sdk.AccountParameterInitialReplicationSizeLimitInTB)). + HasValueString("3.0"), + ), + }, + }, + }) +} + +// TODO(SNOW-1866453): add more acc tests for the remaining parameters diff --git a/pkg/resources/task_parameters.go b/pkg/resources/task_parameters.go index 5609bca254..2f9a1595c8 100644 --- a/pkg/resources/task_parameters.go +++ b/pkg/resources/task_parameters.go @@ -298,7 +298,7 @@ func handleTaskParametersCreate(d *schema.ResourceData, createOpts *sdk.CreateTa handleParameterCreateWithMapping(d, sdk.TaskParameterGeometryOutputFormat, &createOpts.SessionParameters.GeometryOutputFormat, stringToStringEnumProvider(sdk.ToGeometryOutputFormat)), handleParameterCreate(d, sdk.TaskParameterJdbcTreatTimestampNtzAsUtc, &createOpts.SessionParameters.JdbcTreatTimestampNtzAsUtc), handleParameterCreate(d, sdk.TaskParameterJdbcUseSessionTimezone, &createOpts.SessionParameters.JdbcUseSessionTimezone), - handleParameterCreate(d, sdk.TaskParameterJsonIndent, &createOpts.SessionParameters.JSONIndent), + handleParameterCreate(d, sdk.TaskParameterJsonIndent, &createOpts.SessionParameters.JsonIndent), handleParameterCreate(d, sdk.TaskParameterLockTimeout, &createOpts.SessionParameters.LockTimeout), handleParameterCreateWithMapping(d, sdk.TaskParameterLogLevel, &createOpts.SessionParameters.LogLevel, stringToStringEnumProvider(sdk.ToLogLevel)), handleParameterCreate(d, sdk.TaskParameterMultiStatementCount, &createOpts.SessionParameters.MultiStatementCount), @@ -311,7 +311,7 @@ func handleTaskParametersCreate(d *schema.ResourceData, createOpts *sdk.CreateTa handleParameterCreate(d, sdk.TaskParameterSearchPath, &createOpts.SessionParameters.SearchPath), handleParameterCreate(d, sdk.TaskParameterStatementQueuedTimeoutInSeconds, &createOpts.SessionParameters.StatementQueuedTimeoutInSeconds), handleParameterCreate(d, sdk.TaskParameterStatementTimeoutInSeconds, &createOpts.SessionParameters.StatementTimeoutInSeconds), - handleParameterCreate(d, sdk.TaskParameterStrictJsonOutput, &createOpts.SessionParameters.StrictJSONOutput), + handleParameterCreate(d, sdk.TaskParameterStrictJsonOutput, &createOpts.SessionParameters.StrictJsonOutput), handleParameterCreate(d, sdk.TaskParameterTimestampDayIsAlways24h, &createOpts.SessionParameters.TimestampDayIsAlways24h), handleParameterCreate(d, sdk.TaskParameterTimestampInputFormat, &createOpts.SessionParameters.TimestampInputFormat), handleParameterCreate(d, sdk.TaskParameterTimestampLtzOutputFormat, &createOpts.SessionParameters.TimestampLTZOutputFormat), @@ -369,7 +369,7 @@ func handleTaskParametersUpdate(d *schema.ResourceData, set *sdk.TaskSetRequest, handleParameterUpdateWithMapping(d, sdk.TaskParameterGeometryOutputFormat, &set.SessionParameters.GeometryOutputFormat, &unset.SessionParametersUnset.GeometryOutputFormat, stringToStringEnumProvider(sdk.ToGeometryOutputFormat)), handleParameterUpdate(d, sdk.TaskParameterJdbcTreatTimestampNtzAsUtc, &set.SessionParameters.JdbcTreatTimestampNtzAsUtc, &unset.SessionParametersUnset.JdbcTreatTimestampNtzAsUtc), handleParameterUpdate(d, sdk.TaskParameterJdbcUseSessionTimezone, &set.SessionParameters.JdbcUseSessionTimezone, &unset.SessionParametersUnset.JdbcUseSessionTimezone), - handleParameterUpdate(d, sdk.TaskParameterJsonIndent, &set.SessionParameters.JSONIndent, &unset.SessionParametersUnset.JSONIndent), + handleParameterUpdate(d, sdk.TaskParameterJsonIndent, &set.SessionParameters.JsonIndent, &unset.SessionParametersUnset.JsonIndent), handleParameterUpdate(d, sdk.TaskParameterLockTimeout, &set.SessionParameters.LockTimeout, &unset.SessionParametersUnset.LockTimeout), handleParameterUpdateWithMapping(d, sdk.TaskParameterLogLevel, &set.SessionParameters.LogLevel, &unset.SessionParametersUnset.LogLevel, stringToStringEnumProvider(sdk.ToLogLevel)), handleParameterUpdate(d, sdk.TaskParameterMultiStatementCount, &set.SessionParameters.MultiStatementCount, &unset.SessionParametersUnset.MultiStatementCount), @@ -382,7 +382,7 @@ func handleTaskParametersUpdate(d *schema.ResourceData, set *sdk.TaskSetRequest, handleParameterUpdate(d, sdk.TaskParameterSearchPath, &set.SessionParameters.SearchPath, &unset.SessionParametersUnset.SearchPath), handleParameterUpdate(d, sdk.TaskParameterStatementQueuedTimeoutInSeconds, &set.SessionParameters.StatementQueuedTimeoutInSeconds, &unset.SessionParametersUnset.StatementQueuedTimeoutInSeconds), handleParameterUpdate(d, sdk.TaskParameterStatementTimeoutInSeconds, &set.SessionParameters.StatementTimeoutInSeconds, &unset.SessionParametersUnset.StatementTimeoutInSeconds), - handleParameterUpdate(d, sdk.TaskParameterStrictJsonOutput, &set.SessionParameters.StrictJSONOutput, &unset.SessionParametersUnset.StrictJSONOutput), + handleParameterUpdate(d, sdk.TaskParameterStrictJsonOutput, &set.SessionParameters.StrictJsonOutput, &unset.SessionParametersUnset.StrictJsonOutput), handleParameterUpdate(d, sdk.TaskParameterTimestampDayIsAlways24h, &set.SessionParameters.TimestampDayIsAlways24h, &unset.SessionParametersUnset.TimestampDayIsAlways24h), handleParameterUpdate(d, sdk.TaskParameterTimestampInputFormat, &set.SessionParameters.TimestampInputFormat, &unset.SessionParametersUnset.TimestampInputFormat), handleParameterUpdate(d, sdk.TaskParameterTimestampLtzOutputFormat, &set.SessionParameters.TimestampLTZOutputFormat, &unset.SessionParametersUnset.TimestampLTZOutputFormat), diff --git a/pkg/resources/user_parameters.go b/pkg/resources/user_parameters.go index 2c4f34f2ea..61ef7a24ff 100644 --- a/pkg/resources/user_parameters.go +++ b/pkg/resources/user_parameters.go @@ -290,7 +290,7 @@ func handleUserParametersCreate(d *schema.ResourceData, createOpts *sdk.CreateUs handleParameterCreate(d, sdk.UserParameterJdbcTreatDecimalAsInt, &createOpts.SessionParameters.JdbcTreatDecimalAsInt), handleParameterCreate(d, sdk.UserParameterJdbcTreatTimestampNtzAsUtc, &createOpts.SessionParameters.JdbcTreatTimestampNtzAsUtc), handleParameterCreate(d, sdk.UserParameterJdbcUseSessionTimezone, &createOpts.SessionParameters.JdbcUseSessionTimezone), - handleParameterCreate(d, sdk.UserParameterJsonIndent, &createOpts.SessionParameters.JSONIndent), + handleParameterCreate(d, sdk.UserParameterJsonIndent, &createOpts.SessionParameters.JsonIndent), handleParameterCreate(d, sdk.UserParameterLockTimeout, &createOpts.SessionParameters.LockTimeout), handleParameterCreateWithMapping(d, sdk.UserParameterLogLevel, &createOpts.SessionParameters.LogLevel, stringToStringEnumProvider(sdk.ToLogLevel)), handleParameterCreate(d, sdk.UserParameterMultiStatementCount, &createOpts.SessionParameters.MultiStatementCount), @@ -304,7 +304,7 @@ func handleUserParametersCreate(d *schema.ResourceData, createOpts *sdk.CreateUs handleParameterCreate(d, sdk.UserParameterSimulatedDataSharingConsumer, &createOpts.SessionParameters.SimulatedDataSharingConsumer), handleParameterCreate(d, sdk.UserParameterStatementQueuedTimeoutInSeconds, &createOpts.SessionParameters.StatementQueuedTimeoutInSeconds), handleParameterCreate(d, sdk.UserParameterStatementTimeoutInSeconds, &createOpts.SessionParameters.StatementTimeoutInSeconds), - handleParameterCreate(d, sdk.UserParameterStrictJsonOutput, &createOpts.SessionParameters.StrictJSONOutput), + handleParameterCreate(d, sdk.UserParameterStrictJsonOutput, &createOpts.SessionParameters.StrictJsonOutput), handleParameterCreate(d, sdk.UserParameterTimestampDayIsAlways24h, &createOpts.SessionParameters.TimestampDayIsAlways24h), handleParameterCreate(d, sdk.UserParameterTimestampInputFormat, &createOpts.SessionParameters.TimestampInputFormat), handleParameterCreate(d, sdk.UserParameterTimestampLtzOutputFormat, &createOpts.SessionParameters.TimestampLTZOutputFormat), @@ -353,7 +353,7 @@ func handleUserParametersUpdate(d *schema.ResourceData, set *sdk.UserSet, unset handleParameterUpdate(d, sdk.UserParameterJdbcTreatDecimalAsInt, &set.SessionParameters.JdbcTreatDecimalAsInt, &unset.SessionParameters.JdbcTreatDecimalAsInt), handleParameterUpdate(d, sdk.UserParameterJdbcTreatTimestampNtzAsUtc, &set.SessionParameters.JdbcTreatTimestampNtzAsUtc, &unset.SessionParameters.JdbcTreatTimestampNtzAsUtc), handleParameterUpdate(d, sdk.UserParameterJdbcUseSessionTimezone, &set.SessionParameters.JdbcUseSessionTimezone, &unset.SessionParameters.JdbcUseSessionTimezone), - handleParameterUpdate(d, sdk.UserParameterJsonIndent, &set.SessionParameters.JSONIndent, &unset.SessionParameters.JSONIndent), + handleParameterUpdate(d, sdk.UserParameterJsonIndent, &set.SessionParameters.JsonIndent, &unset.SessionParameters.JsonIndent), handleParameterUpdate(d, sdk.UserParameterLockTimeout, &set.SessionParameters.LockTimeout, &unset.SessionParameters.LockTimeout), handleParameterUpdateWithMapping(d, sdk.UserParameterLogLevel, &set.SessionParameters.LogLevel, &unset.SessionParameters.LogLevel, stringToStringEnumProvider(sdk.ToLogLevel)), handleParameterUpdate(d, sdk.UserParameterMultiStatementCount, &set.SessionParameters.MultiStatementCount, &unset.SessionParameters.MultiStatementCount), @@ -367,7 +367,7 @@ func handleUserParametersUpdate(d *schema.ResourceData, set *sdk.UserSet, unset handleParameterUpdate(d, sdk.UserParameterSimulatedDataSharingConsumer, &set.SessionParameters.SimulatedDataSharingConsumer, &unset.SessionParameters.SimulatedDataSharingConsumer), handleParameterUpdate(d, sdk.UserParameterStatementQueuedTimeoutInSeconds, &set.SessionParameters.StatementQueuedTimeoutInSeconds, &unset.SessionParameters.StatementQueuedTimeoutInSeconds), handleParameterUpdate(d, sdk.UserParameterStatementTimeoutInSeconds, &set.SessionParameters.StatementTimeoutInSeconds, &unset.SessionParameters.StatementTimeoutInSeconds), - handleParameterUpdate(d, sdk.UserParameterStrictJsonOutput, &set.SessionParameters.StrictJSONOutput, &unset.SessionParameters.StrictJSONOutput), + handleParameterUpdate(d, sdk.UserParameterStrictJsonOutput, &set.SessionParameters.StrictJsonOutput, &unset.SessionParameters.StrictJsonOutput), handleParameterUpdate(d, sdk.UserParameterTimestampDayIsAlways24h, &set.SessionParameters.TimestampDayIsAlways24h, &unset.SessionParameters.TimestampDayIsAlways24h), handleParameterUpdate(d, sdk.UserParameterTimestampInputFormat, &set.SessionParameters.TimestampInputFormat, &unset.SessionParameters.TimestampInputFormat), handleParameterUpdate(d, sdk.UserParameterTimestampLtzOutputFormat, &set.SessionParameters.TimestampLTZOutputFormat, &unset.SessionParameters.TimestampLTZOutputFormat), diff --git a/pkg/sdk/accounts_test.go b/pkg/sdk/accounts_test.go index e072eabd71..4c66a4c6aa 100644 --- a/pkg/sdk/accounts_test.go +++ b/pkg/sdk/accounts_test.go @@ -111,7 +111,7 @@ func TestAccountAlter(t *testing.T) { PreventUnloadToInternalStages: Bool(true), }, SessionParameters: &SessionParameters{ - JSONIndent: Int(16), + JsonIndent: Int(16), }, ObjectParameters: &ObjectParameters{ MaxDataExtensionTimeInDays: Int(30), diff --git a/pkg/sdk/parameters.go b/pkg/sdk/parameters.go index 377d46a5fd..86551dd14e 100644 --- a/pkg/sdk/parameters.go +++ b/pkg/sdk/parameters.go @@ -66,6 +66,8 @@ func (parameters *parameters) SetAccountParameter(ctx context.Context, parameter return fmt.Errorf("CLIENT_ENCRYPTION_KEY_SIZE session parameter is an integer, got %v", value) } opts.Set.Parameters.AccountParameters.ClientEncryptionKeySize = Pointer(v) + case AccountParameterCortexEnabledCrossRegion: + opts.Set.Parameters.AccountParameters.CortexEnabledCrossRegion = &value case AccountParameterEnableIdentifierFirstLogin: b, err := parseBooleanParameter(string(parameter), value) if err != nil { @@ -78,6 +80,12 @@ func (parameters *parameters) SetAccountParameter(ctx context.Context, parameter return err } opts.Set.Parameters.AccountParameters.AllowIDToken = b + case AccountParameterEnablePersonalDatabase: + b, err := parseBooleanParameter(string(parameter), value) + if err != nil { + return err + } + opts.Set.Parameters.AccountParameters.EnablePersonalDatabase = b case AccountParameterEnableTriSecretAndRekeyOptOutForImageRepository: b, err := parseBooleanParameter(string(parameter), value) if err != nil { @@ -90,6 +98,18 @@ func (parameters *parameters) SetAccountParameter(ctx context.Context, parameter return err } opts.Set.Parameters.AccountParameters.EnableTriSecretAndRekeyOptOutForSpcsBlockStorage = b + case AccountParameterEnableUnhandledExceptionsReporting: + b, err := parseBooleanParameter(string(parameter), value) + if err != nil { + return err + } + opts.Set.Parameters.AccountParameters.EnableUnhandledExceptionsReporting = b + case AccountParameterEnforceNetworkRulesForInternalStages: + b, err := parseBooleanParameter(string(parameter), value) + if err != nil { + return err + } + opts.Set.Parameters.AccountParameters.EnforceNetworkRulesForInternalStages = b case AccountParameterEventTable: opts.Set.Parameters.AccountParameters.EventTable = &value case AccountParameterEnableUnredactedQuerySyntaxError: @@ -105,12 +125,7 @@ func (parameters *parameters) SetAccountParameter(ctx context.Context, parameter } opts.Set.Parameters.AccountParameters.ExternalOAuthAddPrivilegedRolesToBlockedList = b case AccountParameterInitialReplicationSizeLimitInTB: - v, err := strconv.ParseFloat(value, 64) - if err != nil { - return fmt.Errorf("INITIAL_REPLICATION_SIZE_LIMIT_IN_TB session parameter is an integer, got %v", value) - } - opts.Set.Parameters.AccountParameters.InitialReplicationSizeLimitInTB = Pointer(v) - + opts.Set.Parameters.AccountParameters.InitialReplicationSizeLimitInTB = &value case AccountParameterMinDataRetentionTimeInDays: v, err := strconv.Atoi(value) if err != nil { @@ -176,7 +191,7 @@ func (parameters *parameters) SetAccountParameter(ctx context.Context, parameter return nil } -// TODO(next pr): add integration tests +// TODO(SNOW-1866453): add integration tests func (parameters *parameters) UnsetAccountParameter(ctx context.Context, parameter AccountParameter) error { opts := AlterAccountOptions{ Unset: &AccountUnset{ @@ -192,6 +207,8 @@ func (parameters *parameters) UnsetAccountParameter(ctx context.Context, paramet opts.Unset.Parameters.AccountParameters.AllowIDToken = Pointer(true) case AccountParameterClientEncryptionKeySize: opts.Unset.Parameters.AccountParameters.ClientEncryptionKeySize = Pointer(true) + case AccountParameterCortexEnabledCrossRegion: + opts.Unset.Parameters.AccountParameters.CortexEnabledCrossRegion = Pointer(true) case AccountParameterEnableIdentifierFirstLogin: opts.Unset.Parameters.AccountParameters.EnableIdentifierFirstLogin = Pointer(true) case AccountParameterEnableInternalStagesPrivatelink: @@ -200,8 +217,14 @@ func (parameters *parameters) UnsetAccountParameter(ctx context.Context, paramet opts.Unset.Parameters.AccountParameters.EnableTriSecretAndRekeyOptOutForImageRepository = Pointer(true) case AccountParameterEnableTriSecretAndRekeyOptOutForSpcsBlockStorage: opts.Unset.Parameters.AccountParameters.EnableTriSecretAndRekeyOptOutForSpcsBlockStorage = Pointer(true) + case AccountParameterEnablePersonalDatabase: + opts.Unset.Parameters.AccountParameters.EnablePersonalDatabase = Pointer(true) + case AccountParameterEnableUnhandledExceptionsReporting: + opts.Unset.Parameters.AccountParameters.EnableUnhandledExceptionsReporting = Pointer(true) case AccountParameterEnableUnredactedQuerySyntaxError: opts.Unset.Parameters.AccountParameters.EnableUnredactedQuerySyntaxError = Pointer(true) + case AccountParameterEnforceNetworkRulesForInternalStages: + opts.Unset.Parameters.AccountParameters.EnforceNetworkRulesForInternalStages = Pointer(true) case AccountParameterEventTable: opts.Unset.Parameters.AccountParameters.EventTable = Pointer(true) case AccountParameterExternalOAuthAddPrivilegedRolesToBlockedList: @@ -290,7 +313,7 @@ func (parameters *parameters) SetObjectParameterOnAccount(ctx context.Context, p case ObjectParameterDataRetentionTimeInDays: v, err := strconv.Atoi(value) if err != nil { - return fmt.Errorf("DATA_RETENTION_TIME_IN_DAYS session parameter is an integer, got %v", value) + return fmt.Errorf("DATA_RETENTION_TIME_IN_DAYS object parameter is an integer, got %v", value) } opts.Set.Parameters.ObjectParameters.DataRetentionTimeInDays = Pointer(v) case ObjectParameterDefaultDDLCollation: @@ -300,13 +323,13 @@ func (parameters *parameters) SetObjectParameterOnAccount(ctx context.Context, p case ObjectParameterMaxConcurrencyLevel: v, err := strconv.Atoi(value) if err != nil { - return fmt.Errorf("MAX_CONCURRENCY_LEVEL session parameter is an integer, got %v", value) + return fmt.Errorf("MAX_CONCURRENCY_LEVEL object parameter is an integer, got %v", value) } opts.Set.Parameters.ObjectParameters.MaxConcurrencyLevel = Pointer(v) case ObjectParameterMaxDataExtensionTimeInDays: v, err := strconv.Atoi(value) if err != nil { - return fmt.Errorf("MAX_DATA_EXTENSION_TIME_IN_DAYS session parameter is an integer, got %v", value) + return fmt.Errorf("MAX_DATA_EXTENSION_TIME_IN_DAYS object parameter is an integer, got %v", value) } opts.Set.Parameters.ObjectParameters.MaxDataExtensionTimeInDays = Pointer(v) case ObjectParameterPipeExecutionPaused: @@ -324,13 +347,13 @@ func (parameters *parameters) SetObjectParameterOnAccount(ctx context.Context, p case ObjectParameterStatementQueuedTimeoutInSeconds: v, err := strconv.Atoi(value) if err != nil { - return fmt.Errorf("STATEMENT_QUEUED_TIMEOUT_IN_SECONDS session parameter is an integer, got %v", value) + return fmt.Errorf("STATEMENT_QUEUED_TIMEOUT_IN_SECONDS object parameter is an integer, got %v", value) } opts.Set.Parameters.ObjectParameters.StatementQueuedTimeoutInSeconds = Pointer(v) case ObjectParameterStatementTimeoutInSeconds: v, err := strconv.Atoi(value) if err != nil { - return fmt.Errorf("STATEMENT_TIMEOUT_IN_SECONDS session parameter is an integer, got %v", value) + return fmt.Errorf("STATEMENT_TIMEOUT_IN_SECONDS object parameter is an integer, got %v", value) } opts.Set.Parameters.ObjectParameters.StatementTimeoutInSeconds = Pointer(v) case ObjectParameterNetworkPolicy: @@ -341,12 +364,20 @@ func (parameters *parameters) SetObjectParameterOnAccount(ctx context.Context, p return err } opts.Set.Parameters.ObjectParameters.ShareRestrictions = b + case ObjectParameterStorageSerializationPolicy: + opts.Set.Parameters.ObjectParameters.StorageSerializationPolicy = &value case ObjectParameterSuspendTaskAfterNumFailures: v, err := strconv.Atoi(value) if err != nil { - return fmt.Errorf("SUSPEND_TASK_AFTER_NUM_FAILURES session parameter is an integer, got %v", value) + return fmt.Errorf("SUSPEND_TASK_AFTER_NUM_FAILURES object parameter is an integer, got %v", value) } opts.Set.Parameters.ObjectParameters.SuspendTaskAfterNumFailures = Pointer(v) + case ObjectParameterTaskAutoRetryAttempts: + v, err := strconv.Atoi(value) + if err != nil { + return fmt.Errorf("TASK_AUTO_RETRY_ATTEMPTS object parameter is an integer, got %v", value) + } + opts.Set.Parameters.ObjectParameters.TaskAutoRetryAttempts = Pointer(v) case ObjectParameterTraceLevel: opts.Set.Parameters.ObjectParameters.TraceLevel = Pointer(TraceLevel(value)) case ObjectParameterUserTaskManagedInitialWarehouseSize: @@ -354,7 +385,7 @@ func (parameters *parameters) SetObjectParameterOnAccount(ctx context.Context, p case ObjectParameterUserTaskTimeoutMs: v, err := strconv.Atoi(value) if err != nil { - return fmt.Errorf("USER_TASK_TIMEOUT_MS session parameter is an integer, got %v", value) + return fmt.Errorf("USER_TASK_TIMEOUT_MS object parameter is an integer, got %v", value) } opts.Set.Parameters.ObjectParameters.UserTaskTimeoutMs = Pointer(v) case ObjectParameterEnableUnredactedQuerySyntaxError: @@ -402,8 +433,12 @@ func (parameters *parameters) UnsetObjectParameterOnAccount(ctx context.Context, opts.Unset.Parameters.ObjectParameters.NetworkPolicy = Pointer(true) case ObjectParameterShareRestrictions: opts.Unset.Parameters.ObjectParameters.ShareRestrictions = Pointer(true) + case ObjectParameterStorageSerializationPolicy: + opts.Unset.Parameters.ObjectParameters.StorageSerializationPolicy = Pointer(true) case ObjectParameterSuspendTaskAfterNumFailures: opts.Unset.Parameters.ObjectParameters.SuspendTaskAfterNumFailures = Pointer(true) + case ObjectParameterTaskAutoRetryAttempts: + opts.Unset.Parameters.ObjectParameters.TaskAutoRetryAttempts = Pointer(true) case ObjectParameterTraceLevel: opts.Unset.Parameters.ObjectParameters.TraceLevel = Pointer(true) case ObjectParameterUserTaskManagedInitialWarehouseSize: @@ -465,15 +500,17 @@ type AccountParameter string // https://docs.snowflake.com/en/sql-reference/parameters#parameter-hierarchy-and-types // Account Parameters include Session Parameters, Object Parameters and User Parameters const ( - // TODO(next pr): add remaining parameters; also in parameters_impl.go // Account Parameters AccountParameterAllowClientMFACaching AccountParameter = "ALLOW_CLIENT_MFA_CACHING" AccountParameterAllowIDToken AccountParameter = "ALLOW_ID_TOKEN" // #nosec G101 AccountParameterClientEncryptionKeySize AccountParameter = "CLIENT_ENCRYPTION_KEY_SIZE" + AccountParameterCortexEnabledCrossRegion AccountParameter = "CORTEX_ENABLED_CROSS_REGION" AccountParameterEnableIdentifierFirstLogin AccountParameter = "ENABLE_IDENTIFIER_FIRST_LOGIN" AccountParameterEnableInternalStagesPrivatelink AccountParameter = "ENABLE_INTERNAL_STAGES_PRIVATELINK" AccountParameterEnableTriSecretAndRekeyOptOutForImageRepository AccountParameter = "ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_IMAGE_REPOSITORY" // #nosec G101 AccountParameterEnableTriSecretAndRekeyOptOutForSpcsBlockStorage AccountParameter = "ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_SPCS_BLOCK_STORAGE" // #nosec G101 + AccountParameterEnableUnhandledExceptionsReporting AccountParameter = "ENABLE_UNHANDLED_EXCEPTIONS_REPORTING" + AccountParameterEnforceNetworkRulesForInternalStages AccountParameter = "ENFORCE_NETWORK_RULES_FOR_INTERNAL_STAGES" AccountParameterEventTable AccountParameter = "EVENT_TABLE" AccountParameterExternalOAuthAddPrivilegedRolesToBlockedList AccountParameter = "EXTERNAL_OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST" AccountParameterInitialReplicationSizeLimitInTB AccountParameter = "INITIAL_REPLICATION_SIZE_LIMIT_IN_TB" @@ -483,16 +520,17 @@ const ( AccountParameterPeriodicDataRekeying AccountParameter = "PERIODIC_DATA_REKEYING" AccountParameterPreventLoadFromInlineURL AccountParameter = "PREVENT_LOAD_FROM_INLINE_URL" AccountParameterPreventUnloadToInlineURL AccountParameter = "PREVENT_UNLOAD_TO_INLINE_URL" - AccountParameterPreventUnloadToInternalStages AccountParameter = "PREVENT_UNLOAD_TO_INTERNAL_STAGES" AccountParameterRequireStorageIntegrationForStageCreation AccountParameter = "REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION" AccountParameterRequireStorageIntegrationForStageOperation AccountParameter = "REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_OPERATION" AccountParameterSSOLoginPage AccountParameter = "SSO_LOGIN_PAGE" // Session Parameters (inherited) AccountParameterAbortDetachedQuery AccountParameter = "ABORT_DETACHED_QUERY" + AccountParameterActivePythonProfiler AccountParameter = "ACTIVE_PYTHON_PROFILER" AccountParameterAutocommit AccountParameter = "AUTOCOMMIT" AccountParameterBinaryInputFormat AccountParameter = "BINARY_INPUT_FORMAT" AccountParameterBinaryOutputFormat AccountParameter = "BINARY_OUTPUT_FORMAT" + AccountParameterClientEnableLogInfoStatementParameters AccountParameter = "CLIENT_ENABLE_LOG_INFO_STATEMENT_PARAMETERS" AccountParameterClientMemoryLimit AccountParameter = "CLIENT_MEMORY_LIMIT" AccountParameterClientMetadataRequestUseConnectionCtx AccountParameter = "CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX" AccountParameterClientMetadataUseSessionDatabase AccountParameter = "CLIENT_METADATA_USE_SESSION_DATABASE" @@ -502,6 +540,7 @@ const ( AccountParameterClientSessionKeepAlive AccountParameter = "CLIENT_SESSION_KEEP_ALIVE" AccountParameterClientSessionKeepAliveHeartbeatFrequency AccountParameter = "CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY" AccountParameterClientTimestampTypeMapping AccountParameter = "CLIENT_TIMESTAMP_TYPE_MAPPING" + AccountParameterCsvTimestampFormat AccountParameter = "CSV_TIMESTAMP_FORMAT" AccountParameterDateInputFormat AccountParameter = "DATE_INPUT_FORMAT" AccountParameterDateOutputFormat AccountParameter = "DATE_OUTPUT_FORMAT" AccountParameterEnableUnloadPhysicalTypeOptimization AccountParameter = "ENABLE_UNLOAD_PHYSICAL_TYPE_OPTIMIZATION" @@ -509,22 +548,25 @@ const ( AccountParameterErrorOnNondeterministicUpdate AccountParameter = "ERROR_ON_NONDETERMINISTIC_UPDATE" AccountParameterGeographyOutputFormat AccountParameter = "GEOGRAPHY_OUTPUT_FORMAT" AccountParameterGeometryOutputFormat AccountParameter = "GEOMETRY_OUTPUT_FORMAT" + AccountParameterHybridTableLockTimeout AccountParameter = "HYBRID_TABLE_LOCK_TIMEOUT" AccountParameterJdbcTreatDecimalAsInt AccountParameter = "JDBC_TREAT_DECIMAL_AS_INT" AccountParameterJdbcTreatTimestampNtzAsUtc AccountParameter = "JDBC_TREAT_TIMESTAMP_NTZ_AS_UTC" AccountParameterJdbcUseSessionTimezone AccountParameter = "JDBC_USE_SESSION_TIMEZONE" - AccountParameterJSONIndent AccountParameter = "JSON_INDENT" + AccountParameterJsonIndent AccountParameter = "JSON_INDENT" + AccountParameterJsTreatIntegerAsBigInt AccountParameter = "JS_TREAT_INTEGER_AS_BIGINT" AccountParameterLockTimeout AccountParameter = "LOCK_TIMEOUT" AccountParameterMultiStatementCount AccountParameter = "MULTI_STATEMENT_COUNT" AccountParameterNoorderSequenceAsDefault AccountParameter = "NOORDER_SEQUENCE_AS_DEFAULT" AccountParameterOdbcTreatDecimalAsInt AccountParameter = "ODBC_TREAT_DECIMAL_AS_INT" + AccountParameterPythonProfilerModules AccountParameter = "PYTHON_PROFILER_MODULES" + AccountParameterPythonProfilerTargetStage AccountParameter = "PYTHON_PROFILER_TARGET_STAGE" AccountParameterQueryTag AccountParameter = "QUERY_TAG" AccountParameterQuotedIdentifiersIgnoreCase AccountParameter = "QUOTED_IDENTIFIERS_IGNORE_CASE" AccountParameterRowsPerResultset AccountParameter = "ROWS_PER_RESULTSET" AccountParameterS3StageVpceDnsName AccountParameter = "S3_STAGE_VPCE_DNS_NAME" AccountParameterSearchPath AccountParameter = "SEARCH_PATH" AccountParameterSimulatedDataSharingConsumer AccountParameter = "SIMULATED_DATA_SHARING_CONSUMER" - AccountParameterStatementTimeoutInSeconds AccountParameter = "STATEMENT_TIMEOUT_IN_SECONDS" - AccountParameterStrictJSONOutput AccountParameter = "STRICT_JSON_OUTPUT" + AccountParameterStrictJsonOutput AccountParameter = "STRICT_JSON_OUTPUT" AccountParameterTimeInputFormat AccountParameter = "TIME_INPUT_FORMAT" AccountParameterTimeOutputFormat AccountParameter = "TIME_OUTPUT_FORMAT" AccountParameterTimestampDayIsAlways24h AccountParameter = "TIMESTAMP_DAY_IS_ALWAYS_24H" @@ -554,6 +596,7 @@ const ( AccountParameterPipeExecutionPaused AccountParameter = "PIPE_EXECUTION_PAUSED" AccountParameterReplaceInvalidCharacters AccountParameter = "REPLACE_INVALID_CHARACTERS" AccountParameterStatementQueuedTimeoutInSeconds AccountParameter = "STATEMENT_QUEUED_TIMEOUT_IN_SECONDS" + AccountParameterStatementTimeoutInSeconds AccountParameter = "STATEMENT_TIMEOUT_IN_SECONDS" AccountParameterStorageSerializationPolicy AccountParameter = "STORAGE_SERIALIZATION_POLICY" AccountParameterShareRestrictions AccountParameter = "SHARE_RESTRICTIONS" AccountParameterSuspendTaskAfterNumFailures AccountParameter = "SUSPEND_TASK_AFTER_NUM_FAILURES" @@ -566,17 +609,22 @@ const ( AccountParameterEnableConsoleOutput AccountParameter = "ENABLE_CONSOLE_OUTPUT" // User Parameters (inherited) + AccountParameterEnablePersonalDatabase AccountParameter = "ENABLE_PERSONAL_DATABASE" AccountParameterEnableUnredactedQuerySyntaxError AccountParameter = "ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR" + AccountParameterPreventUnloadToInternalStages AccountParameter = "PREVENT_UNLOAD_TO_INTERNAL_STAGES" ) var AllAccountParameters = []AccountParameter{ AccountParameterAllowClientMFACaching, AccountParameterAllowIDToken, AccountParameterClientEncryptionKeySize, + AccountParameterCortexEnabledCrossRegion, AccountParameterEnableIdentifierFirstLogin, AccountParameterEnableInternalStagesPrivatelink, AccountParameterEnableTriSecretAndRekeyOptOutForImageRepository, AccountParameterEnableTriSecretAndRekeyOptOutForSpcsBlockStorage, + AccountParameterEnableUnhandledExceptionsReporting, + AccountParameterEnforceNetworkRulesForInternalStages, AccountParameterEventTable, AccountParameterExternalOAuthAddPrivilegedRolesToBlockedList, AccountParameterInitialReplicationSizeLimitInTB, @@ -586,14 +634,16 @@ var AllAccountParameters = []AccountParameter{ AccountParameterPeriodicDataRekeying, AccountParameterPreventLoadFromInlineURL, AccountParameterPreventUnloadToInlineURL, - AccountParameterPreventUnloadToInternalStages, AccountParameterRequireStorageIntegrationForStageCreation, AccountParameterRequireStorageIntegrationForStageOperation, AccountParameterSSOLoginPage, + AccountParameterAbortDetachedQuery, + AccountParameterActivePythonProfiler, AccountParameterAutocommit, AccountParameterBinaryInputFormat, AccountParameterBinaryOutputFormat, + AccountParameterClientEnableLogInfoStatementParameters, AccountParameterClientMemoryLimit, AccountParameterClientMetadataRequestUseConnectionCtx, AccountParameterClientMetadataUseSessionDatabase, @@ -604,20 +654,25 @@ var AllAccountParameters = []AccountParameter{ AccountParameterClientTimestampTypeMapping, AccountParameterEnableUnloadPhysicalTypeOptimization, AccountParameterClientResultColumnCaseInsensitive, + AccountParameterCsvTimestampFormat, AccountParameterDateInputFormat, AccountParameterDateOutputFormat, AccountParameterErrorOnNondeterministicMerge, AccountParameterErrorOnNondeterministicUpdate, AccountParameterGeographyOutputFormat, AccountParameterGeometryOutputFormat, + AccountParameterHybridTableLockTimeout, AccountParameterJdbcTreatDecimalAsInt, AccountParameterJdbcTreatTimestampNtzAsUtc, AccountParameterJdbcUseSessionTimezone, - AccountParameterJSONIndent, + AccountParameterJsonIndent, + AccountParameterJsTreatIntegerAsBigInt, AccountParameterLockTimeout, AccountParameterMultiStatementCount, AccountParameterNoorderSequenceAsDefault, AccountParameterOdbcTreatDecimalAsInt, + AccountParameterPythonProfilerModules, + AccountParameterPythonProfilerTargetStage, AccountParameterQueryTag, AccountParameterQuotedIdentifiersIgnoreCase, AccountParameterRowsPerResultset, @@ -625,7 +680,7 @@ var AllAccountParameters = []AccountParameter{ AccountParameterSearchPath, AccountParameterSimulatedDataSharingConsumer, AccountParameterStatementTimeoutInSeconds, - AccountParameterStrictJSONOutput, + AccountParameterStrictJsonOutput, AccountParameterTimeInputFormat, AccountParameterTimeOutputFormat, AccountParameterTimestampDayIsAlways24h, @@ -643,6 +698,7 @@ var AllAccountParameters = []AccountParameter{ AccountParameterUseCachedResult, AccountParameterWeekOfYearPolicy, AccountParameterWeekStart, + AccountParameterCatalog, AccountParameterDataRetentionTimeInDays, AccountParameterDefaultDDLCollation, @@ -665,6 +721,7 @@ var AllAccountParameters = []AccountParameter{ AccountParameterMetricLevel, AccountParameterEnableConsoleOutput, AccountParameterEnableUnredactedQuerySyntaxError, + AccountParameterEnablePersonalDatabase, } func ToAccountParameter(s string) (AccountParameter, error) { @@ -679,9 +736,11 @@ type SessionParameter string const ( SessionParameterAbortDetachedQuery SessionParameter = "ABORT_DETACHED_QUERY" + SessionParameterActivePythonProfiler SessionParameter = "ACTIVE_PYTHON_PROFILER" SessionParameterAutocommit SessionParameter = "AUTOCOMMIT" SessionParameterBinaryInputFormat SessionParameter = "BINARY_INPUT_FORMAT" SessionParameterBinaryOutputFormat SessionParameter = "BINARY_OUTPUT_FORMAT" + SessionParameterClientEnableLogInfoStatementParameters SessionParameter = "CLIENT_ENABLE_LOG_INFO_STATEMENT_PARAMETERS" SessionParameterClientMemoryLimit SessionParameter = "CLIENT_MEMORY_LIMIT" SessionParameterClientMetadataRequestUseConnectionCtx SessionParameter = "CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX" SessionParameterClientPrefetchThreads SessionParameter = "CLIENT_PREFETCH_THREADS" @@ -691,6 +750,7 @@ const ( SessionParameterClientSessionKeepAlive SessionParameter = "CLIENT_SESSION_KEEP_ALIVE" SessionParameterClientSessionKeepAliveHeartbeatFrequency SessionParameter = "CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY" SessionParameterClientTimestampTypeMapping SessionParameter = "CLIENT_TIMESTAMP_TYPE_MAPPING" + SessionParameterCsvTimestampFormat SessionParameter = "CSV_TIMESTAMP_FORMAT" SessionParameterDateInputFormat SessionParameter = "DATE_INPUT_FORMAT" SessionParameterDateOutputFormat SessionParameter = "DATE_OUTPUT_FORMAT" SessionParameterEnableUnloadPhysicalTypeOptimization SessionParameter = "ENABLE_UNLOAD_PHYSICAL_TYPE_OPTIMIZATION" @@ -698,15 +758,19 @@ const ( SessionParameterErrorOnNondeterministicUpdate SessionParameter = "ERROR_ON_NONDETERMINISTIC_UPDATE" SessionParameterGeographyOutputFormat SessionParameter = "GEOGRAPHY_OUTPUT_FORMAT" SessionParameterGeometryOutputFormat SessionParameter = "GEOMETRY_OUTPUT_FORMAT" + SessionParameterHybridTableLockTimeout SessionParameter = "HYBRID_TABLE_LOCK_TIMEOUT" 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" + SessionParameterJsonIndent SessionParameter = "JSON_INDENT" + SessionParameterJsTreatIntegerAsBigInt SessionParameter = "JS_TREAT_INTEGER_AS_BIGINT" 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" + SessionParameterPythonProfilerModules SessionParameter = "PYTHON_PROFILER_MODULES" + SessionParameterPythonProfilerTargetStage SessionParameter = "PYTHON_PROFILER_TARGET_STAGE" SessionParameterQueryTag SessionParameter = "QUERY_TAG" SessionParameterQuotedIdentifiersIgnoreCase SessionParameter = "QUOTED_IDENTIFIERS_IGNORE_CASE" SessionParameterRowsPerResultset SessionParameter = "ROWS_PER_RESULTSET" @@ -715,7 +779,7 @@ const ( SessionParameterSimulatedDataSharingConsumer SessionParameter = "SIMULATED_DATA_SHARING_CONSUMER" SessionParameterStatementQueuedTimeoutInSeconds SessionParameter = "STATEMENT_QUEUED_TIMEOUT_IN_SECONDS" SessionParameterStatementTimeoutInSeconds SessionParameter = "STATEMENT_TIMEOUT_IN_SECONDS" - SessionParameterStrictJSONOutput SessionParameter = "STRICT_JSON_OUTPUT" + SessionParameterStrictJsonOutput SessionParameter = "STRICT_JSON_OUTPUT" SessionParameterTimestampDayIsAlways24h SessionParameter = "TIMESTAMP_DAY_IS_ALWAYS_24H" SessionParameterTimestampInputFormat SessionParameter = "TIMESTAMP_INPUT_FORMAT" SessionParameterTimestampLTZOutputFormat SessionParameter = "TIMESTAMP_LTZ_OUTPUT_FORMAT" @@ -1111,44 +1175,51 @@ var AllProcedureParameters = []ProcedureParameter{ // AccountParameters is based on https://docs.snowflake.com/en/sql-reference/parameters#account-parameters. type AccountParameters struct { // Account Parameters - AllowClientMFACaching *bool `ddl:"parameter" sql:"ALLOW_CLIENT_MFA_CACHING"` - AllowIDToken *bool `ddl:"parameter" sql:"ALLOW_ID_TOKEN"` - ClientEncryptionKeySize *int `ddl:"parameter" sql:"CLIENT_ENCRYPTION_KEY_SIZE"` - EnableIdentifierFirstLogin *bool `ddl:"parameter" sql:"ENABLE_IDENTIFIER_FIRST_LOGIN"` - EnableInternalStagesPrivatelink *bool `ddl:"parameter" sql:"ENABLE_INTERNAL_STAGES_PRIVATELINK"` - EnableUnredactedQuerySyntaxError *bool `ddl:"parameter" sql:"ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR"` - EnableTriSecretAndRekeyOptOutForImageRepository *bool `ddl:"parameter" sql:"ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_IMAGE_REPOSITORY"` - EnableTriSecretAndRekeyOptOutForSpcsBlockStorage *bool `ddl:"parameter" sql:"ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_SPCS_BLOCK_STORAGE"` - EventTable *string `ddl:"parameter,single_quotes" sql:"EVENT_TABLE"` - ExternalOAuthAddPrivilegedRolesToBlockedList *bool `ddl:"parameter" sql:"EXTERNAL_OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST"` - InitialReplicationSizeLimitInTB *float64 `ddl:"parameter" sql:"INITIAL_REPLICATION_SIZE_LIMIT_IN_TB"` - MinDataRetentionTimeInDays *int `ddl:"parameter" sql:"MIN_DATA_RETENTION_TIME_IN_DAYS"` - NetworkPolicy *string `ddl:"parameter,single_quotes" sql:"NETWORK_POLICY"` - OAuthAddPrivilegedRolesToBlockedList *bool `ddl:"parameter" sql:"OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST"` - PeriodicDataRekeying *bool `ddl:"parameter" sql:"PERIODIC_DATA_REKEYING"` - PreventLoadFromInlineURL *bool `ddl:"parameter" sql:"PREVENT_LOAD_FROM_INLINE_URL"` - PreventUnloadToInlineURL *bool `ddl:"parameter" sql:"PREVENT_UNLOAD_TO_INLINE_URL"` - PreventUnloadToInternalStages *bool `ddl:"parameter" sql:"PREVENT_UNLOAD_TO_INTERNAL_STAGES"` - RequireStorageIntegrationForStageCreation *bool `ddl:"parameter" sql:"REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION"` - RequireStorageIntegrationForStageOperation *bool `ddl:"parameter" sql:"REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_OPERATION"` - SSOLoginPage *bool `ddl:"parameter" sql:"SSO_LOGIN_PAGE"` + AllowClientMFACaching *bool `ddl:"parameter" sql:"ALLOW_CLIENT_MFA_CACHING"` + AllowIDToken *bool `ddl:"parameter" sql:"ALLOW_ID_TOKEN"` + ClientEncryptionKeySize *int `ddl:"parameter" sql:"CLIENT_ENCRYPTION_KEY_SIZE"` + CortexEnabledCrossRegion *string `ddl:"parameter,single_quotes" sql:"CORTEX_ENABLED_CROSS_REGION"` + EnableIdentifierFirstLogin *bool `ddl:"parameter" sql:"ENABLE_IDENTIFIER_FIRST_LOGIN"` + EnableInternalStagesPrivatelink *bool `ddl:"parameter" sql:"ENABLE_INTERNAL_STAGES_PRIVATELINK"` + EnablePersonalDatabase *bool `ddl:"parameter" sql:"ENABLE_PERSONAL_DATABASE"` + EnableUnredactedQuerySyntaxError *bool `ddl:"parameter" sql:"ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR"` + EnableTriSecretAndRekeyOptOutForImageRepository *bool `ddl:"parameter" sql:"ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_IMAGE_REPOSITORY"` + EnableTriSecretAndRekeyOptOutForSpcsBlockStorage *bool `ddl:"parameter" sql:"ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_SPCS_BLOCK_STORAGE"` + EnableUnhandledExceptionsReporting *bool `ddl:"parameter" sql:"ENABLE_UNHANDLED_EXCEPTIONS_REPORTING"` + EnforceNetworkRulesForInternalStages *bool `ddl:"keyword" sql:"ENFORCE_NETWORK_RULES_FOR_INTERNAL_STAGES"` + EventTable *string `ddl:"parameter,single_quotes" sql:"EVENT_TABLE"` + ExternalOAuthAddPrivilegedRolesToBlockedList *bool `ddl:"parameter" sql:"EXTERNAL_OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST"` + // InitialReplicationSizeLimitInTB is a string because values like 3.0 get rounded to 3, resulting in an error in Snowflake. + // This is still validated below. + InitialReplicationSizeLimitInTB *string `ddl:"parameter" sql:"INITIAL_REPLICATION_SIZE_LIMIT_IN_TB"` + MinDataRetentionTimeInDays *int `ddl:"parameter" sql:"MIN_DATA_RETENTION_TIME_IN_DAYS"` + NetworkPolicy *string `ddl:"parameter,single_quotes" sql:"NETWORK_POLICY"` + OAuthAddPrivilegedRolesToBlockedList *bool `ddl:"parameter" sql:"OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST"` + PeriodicDataRekeying *bool `ddl:"parameter" sql:"PERIODIC_DATA_REKEYING"` + PreventLoadFromInlineURL *bool `ddl:"parameter" sql:"PREVENT_LOAD_FROM_INLINE_URL"` + PreventUnloadToInlineURL *bool `ddl:"parameter" sql:"PREVENT_UNLOAD_TO_INLINE_URL"` + PreventUnloadToInternalStages *bool `ddl:"parameter" sql:"PREVENT_UNLOAD_TO_INTERNAL_STAGES"` + RequireStorageIntegrationForStageCreation *bool `ddl:"parameter" sql:"REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION"` + RequireStorageIntegrationForStageOperation *bool `ddl:"parameter" sql:"REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_OPERATION"` + SSOLoginPage *bool `ddl:"parameter" sql:"SSO_LOGIN_PAGE"` } func (v *AccountParameters) validate() error { var errs []error if valueSet(v.ClientEncryptionKeySize) { - if !(*v.ClientEncryptionKeySize == 128 || *v.ClientEncryptionKeySize == 256) { - errs = append(errs, fmt.Errorf("CLIENT_ENCRYPTION_KEY_SIZE must be either 128 or 256")) + if !slices.Contains([]int{128, 256}, *v.ClientEncryptionKeySize) { + errs = append(errs, fmt.Errorf("ClientEncryptionKeySize must be either 128 or 256, got %d", *v.ClientEncryptionKeySize)) } } if valueSet(v.InitialReplicationSizeLimitInTB) { - l := *v.InitialReplicationSizeLimitInTB - if l < 0.0 || (l < 0.0 && l < 1.0) { - errs = append(errs, fmt.Errorf("%v must be 0.0 and above with a scale of at least 1 (e.g. 20.5, 32.25, 33.333, etc.)", l)) + value, err := strconv.ParseFloat(*v.InitialReplicationSizeLimitInTB, 64) + if err != nil || value < 0 { + return fmt.Errorf("InitialReplicationSizeLimitInTB must be a non-negative float, got %v", *v.InitialReplicationSizeLimitInTB) } + } if valueSet(v.MinDataRetentionTimeInDays) { - if !validateIntInRange(*v.MinDataRetentionTimeInDays, 0, 90) { + if !validateIntInRangeInclusive(*v.MinDataRetentionTimeInDays, 0, 90) { errs = append(errs, errIntBetween("AccountParameters", "MinDataRetentionTimeInDays", 0, 90)) } } @@ -1159,12 +1230,16 @@ type AccountParametersUnset struct { AllowClientMFACaching *bool `ddl:"keyword" sql:"ALLOW_CLIENT_MFA_CACHING"` AllowIDToken *bool `ddl:"keyword" sql:"ALLOW_ID_TOKEN"` ClientEncryptionKeySize *bool `ddl:"keyword" sql:"CLIENT_ENCRYPTION_KEY_SIZE"` + CortexEnabledCrossRegion *bool `ddl:"keyword" sql:"CORTEX_ENABLED_CROSS_REGION"` EnableIdentifierFirstLogin *bool `ddl:"keyword" sql:"ENABLE_IDENTIFIER_FIRST_LOGIN"` EnableInternalStagesPrivatelink *bool `ddl:"keyword" sql:"ENABLE_INTERNAL_STAGES_PRIVATELINK"` + EnablePersonalDatabase *bool `ddl:"keyword" sql:"ENABLE_PERSONAL_DATABASE"` EnableTriSecretAndRekeyOptOutForImageRepository *bool `ddl:"keyword" sql:"ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_IMAGE_REPOSITORY"` EnableTriSecretAndRekeyOptOutForSpcsBlockStorage *bool `ddl:"keyword" sql:"ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_SPCS_BLOCK_STORAGE"` + EnableUnhandledExceptionsReporting *bool `ddl:"keyword" sql:"ENABLE_UNHANDLED_EXCEPTIONS_REPORTING"` EventTable *bool `ddl:"keyword" sql:"EVENT_TABLE"` EnableUnredactedQuerySyntaxError *bool `ddl:"keyword" sql:"ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR"` + EnforceNetworkRulesForInternalStages *bool `ddl:"keyword" sql:"ENFORCE_NETWORK_RULES_FOR_INTERNAL_STAGES"` ExternalOAuthAddPrivilegedRolesToBlockedList *bool `ddl:"keyword" sql:"EXTERNAL_OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST"` InitialReplicationSizeLimitInTB *bool `ddl:"keyword" sql:"INITIAL_REPLICATION_SIZE_LIMIT_IN_TB"` MinDataRetentionTimeInDays *bool `ddl:"keyword" sql:"MIN_DATA_RETENTION_TIME_IN_DAYS"` @@ -1179,6 +1254,24 @@ type AccountParametersUnset struct { SSOLoginPage *bool `ddl:"keyword" sql:"SSO_LOGIN_PAGE"` } +type ActivePythonProfiler string + +const ( + ActivePythonProfilerLine ActivePythonProfiler = "LINE" + ActivePythonProfilerMemory ActivePythonProfiler = "MEMORY" +) + +func ToActivePythonProfiler(s string) (ActivePythonProfiler, error) { + switch strings.ToUpper(s) { + case string(ActivePythonProfilerLine): + return ActivePythonProfilerLine, nil + case string(ActivePythonProfilerMemory): + return ActivePythonProfilerMemory, nil + default: + return "", fmt.Errorf("invalid active python profiler: %s", s) + } +} + type GeographyOutputFormat string const ( @@ -1347,9 +1440,11 @@ func ToUnsupportedDDLAction(s string) (UnsupportedDDLAction, error) { // 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"` + ActivePythonProfiler *ActivePythonProfiler `ddl:"parameter,single_quotes" sql:"ACTIVE_PYTHON_PROFILER"` 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"` + ClientEnableLogInfoStatementParameters *bool `ddl:"parameter" sql:"CLIENT_ENABLE_LOG_INFO_STATEMENT_PARAMETERS"` 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"` @@ -1359,6 +1454,7 @@ type SessionParameters struct { 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"` + CsvTimestampFormat *string `ddl:"parameter" sql:"CSV_TIMESTAMP_FORMAT"` 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"` @@ -1366,15 +1462,19 @@ type SessionParameters struct { 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"` + HybridTableLockTimeout *int `ddl:"parameter" sql:"HYBRID_TABLE_LOCK_TIMEOUT"` 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"` + JsonIndent *int `ddl:"parameter" sql:"JSON_INDENT"` + JsTreatIntegerAsBigInt *bool `ddl:"parameter" sql:"JS_TREAT_INTEGER_AS_BIGINT"` 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"` + PythonProfilerModules *string `ddl:"parameter" sql:"PYTHON_PROFILER_MODULES"` + PythonProfilerTargetStage *string `ddl:"parameter" sql:"PYTHON_PROFILER_TARGET_STAGE"` 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"` @@ -1383,7 +1483,7 @@ type SessionParameters struct { 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"` + 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"` @@ -1406,9 +1506,31 @@ type SessionParameters struct { func (v *SessionParameters) validate() error { var errs []error - if valueSet(v.JSONIndent) { - if !validateIntInRange(*v.JSONIndent, 0, 16) { - errs = append(errs, errIntBetween("SessionParameters", "JSONIndent", 0, 16)) + // Do not validate input and output formats, because there are a lot of them, and may be not supported in Go itself. + // See https://docs.snowflake.com/en/sql-reference/date-time-input-output#supported-formats-for-auto-detection. + if valueSet(v.ClientPrefetchThreads) { + if !validateIntGreaterThanOrEqual(*v.ClientPrefetchThreads, 0) { + errs = append(errs, errIntValue("SessionParameters", "ClientPrefetchThreads", IntErrGreaterOrEqual, 0)) + } + } + if valueSet(v.ClientResultChunkSize) { + if !validateIntGreaterThanOrEqual(*v.ClientResultChunkSize, 0) { + errs = append(errs, errIntValue("SessionParameters", "ClientResultChunkSize", IntErrGreaterOrEqual, 0)) + } + } + if valueSet(v.ClientSessionKeepAliveHeartbeatFrequency) { + if !validateIntGreaterThanOrEqual(*v.ClientSessionKeepAliveHeartbeatFrequency, 0) { + errs = append(errs, errIntValue("SessionParameters", "ClientSessionKeepAliveHeartbeatFrequency", IntErrGreaterOrEqual, 0)) + } + } + if valueSet(v.HybridTableLockTimeout) { + if !validateIntGreaterThanOrEqual(*v.HybridTableLockTimeout, 0) { + errs = append(errs, errIntValue("SessionParameters", "HybridTableLockTimeout", IntErrGreaterOrEqual, 0)) + } + } + if valueSet(v.JsonIndent) { + if !validateIntGreaterThanOrEqual(*v.JsonIndent, 0) { + errs = append(errs, errIntValue("SessionParameters", "JsonIndent", IntErrGreaterOrEqual, 0)) } } if valueSet(v.LockTimeout) { @@ -1416,9 +1538,9 @@ func (v *SessionParameters) validate() error { errs = append(errs, errIntValue("SessionParameters", "LockTimeout", IntErrGreaterOrEqual, 0)) } } - if valueSet(v.QueryTag) { - if len(*v.QueryTag) > 2000 { - errs = append(errs, errIntValue("SessionParameters", "QueryTag", IntErrLess, 2000)) + if valueSet(v.MultiStatementCount) { + if !validateIntGreaterThanOrEqual(*v.MultiStatementCount, 0) { + errs = append(errs, errIntValue("SessionParameters", "MultiStatementCount", IntErrGreaterOrEqual, 0)) } } if valueSet(v.RowsPerResultset) { @@ -1426,19 +1548,29 @@ func (v *SessionParameters) validate() error { errs = append(errs, errIntValue("SessionParameters", "RowsPerResultset", IntErrGreaterOrEqual, 0)) } } + if valueSet(v.StatementQueuedTimeoutInSeconds) { + if !validateIntGreaterThanOrEqual(*v.StatementQueuedTimeoutInSeconds, 0) { + errs = append(errs, errIntValue("SessionParameters", "StatementQueuedTimeoutInSeconds", IntErrGreaterOrEqual, 0)) + } + } + if valueSet(v.StatementTimeoutInSeconds) { + if !validateIntGreaterThanOrEqual(*v.StatementTimeoutInSeconds, 0) { + errs = append(errs, errIntValue("SessionParameters", "StatementTimeoutInSeconds", IntErrGreaterOrEqual, 0)) + } + } if valueSet(v.TwoDigitCenturyStart) { - if !validateIntInRange(*v.TwoDigitCenturyStart, 1900, 2100) { - errs = append(errs, errIntBetween("SessionParameters", "TwoDigitCenturyStart", 1900, 2100)) + if !validateIntGreaterThanOrEqual(*v.TwoDigitCenturyStart, 1900) { + errs = append(errs, errIntValue("SessionParameters", "TwoDigitCenturyStart", IntErrGreaterOrEqual, 1900)) } } if valueSet(v.WeekOfYearPolicy) { - if !validateIntInRange(*v.WeekOfYearPolicy, 0, 1) { - errs = append(errs, fmt.Errorf("WEEK_OF_YEAR_POLICY must be either 0 or 1")) + if !validateIntGreaterThanOrEqual(*v.WeekOfYearPolicy, 0) { + errs = append(errs, errIntValue("SessionParameters", "WeekOfYearPolicy", IntErrGreaterOrEqual, 0)) } } if valueSet(v.WeekStart) { - if !validateIntInRange(*v.WeekStart, 0, 1) { - errs = append(errs, fmt.Errorf("WEEK_START must be either 0 or 1")) + if !validateIntGreaterThanOrEqual(*v.WeekStart, 0) { + errs = append(errs, errIntValue("SessionParameters", "WeekStart", IntErrGreaterOrEqual, 0)) } } return errors.Join(errs...) @@ -1446,9 +1578,11 @@ func (v *SessionParameters) validate() error { type SessionParametersUnset struct { AbortDetachedQuery *bool `ddl:"keyword" sql:"ABORT_DETACHED_QUERY"` + ActivePythonProfiler *bool `ddl:"keyword" sql:"ACTIVE_PYTHON_PROFILER"` Autocommit *bool `ddl:"keyword" sql:"AUTOCOMMIT"` BinaryInputFormat *bool `ddl:"keyword" sql:"BINARY_INPUT_FORMAT"` BinaryOutputFormat *bool `ddl:"keyword" sql:"BINARY_OUTPUT_FORMAT"` + ClientEnableLogInfoStatementParameters *bool `ddl:"keyword" sql:"CLIENT_ENABLE_LOG_INFO_STATEMENT_PARAMETERS"` 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"` @@ -1458,6 +1592,7 @@ type SessionParametersUnset struct { 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"` + CsvTimestampFormat *bool `ddl:"keyword" sql:"CSV_TIMESTAMP_FORMAT"` 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"` @@ -1465,15 +1600,19 @@ type SessionParametersUnset struct { 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"` + HybridTableLockTimeout *bool `ddl:"keyword" sql:"HYBRID_TABLE_LOCK_TIMEOUT"` 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"` + JsonIndent *bool `ddl:"keyword" sql:"JSON_INDENT"` + JsTreatIntegerAsBigInt *bool `ddl:"keyword" sql:"JS_TREAT_INTEGER_AS_BIGINT"` 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"` + PythonProfilerModules *bool `ddl:"keyword" sql:"PYTHON_PROFILER_MODULES"` + PythonProfilerTargetStage *bool `ddl:"keyword" sql:"PYTHON_PROFILER_TARGET_STAGE"` QueryTag *bool `ddl:"keyword" sql:"QUERY_TAG"` QuotedIdentifiersIgnoreCase *bool `ddl:"keyword" sql:"QUOTED_IDENTIFIERS_IGNORE_CASE"` RowsPerResultset *bool `ddl:"keyword" sql:"ROWS_PER_RESULTSET"` @@ -1482,7 +1621,7 @@ type SessionParametersUnset struct { 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"` + 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"` @@ -1504,37 +1643,40 @@ type SessionParametersUnset struct { } func (v *SessionParametersUnset) validate() error { - 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")) + if !anyValueSet(v.AbortDetachedQuery, v.ActivePythonProfiler, v.Autocommit, v.BinaryInputFormat, v.BinaryOutputFormat, v.ClientEnableLogInfoStatementParameters, v.ClientMemoryLimit, v.ClientMetadataRequestUseConnectionCtx, v.ClientPrefetchThreads, v.ClientResultChunkSize, v.ClientResultColumnCaseInsensitive, v.ClientMetadataUseSessionDatabase, v.ClientSessionKeepAlive, v.ClientSessionKeepAliveHeartbeatFrequency, v.ClientTimestampTypeMapping, v.CsvTimestampFormat, v.DateInputFormat, v.DateOutputFormat, v.EnableUnloadPhysicalTypeOptimization, v.ErrorOnNondeterministicMerge, v.ErrorOnNondeterministicUpdate, v.GeographyOutputFormat, v.GeometryOutputFormat, v.HybridTableLockTimeout, v.JdbcTreatDecimalAsInt, v.JdbcTreatTimestampNtzAsUtc, v.JdbcUseSessionTimezone, v.JsonIndent, v.JsTreatIntegerAsBigInt, v.LockTimeout, v.LogLevel, v.MultiStatementCount, v.NoorderSequenceAsDefault, v.OdbcTreatDecimalAsInt, v.PythonProfilerModules, v.PythonProfilerTargetStage, 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", "ActivePythonProfiler", "Autocommit", "BinaryInputFormat", "BinaryOutputFormat", "ClientEnableLogInfoStatementParameters", "ClientMemoryLimit", "ClientMetadataRequestUseConnectionCtx", "ClientPrefetchThreads", "ClientResultChunkSize", "ClientResultColumnCaseInsensitive", "ClientMetadataUseSessionDatabase", "ClientSessionKeepAlive", "ClientSessionKeepAliveHeartbeatFrequency", "ClientTimestampTypeMapping", "CsvTimestampFormat", "DateInputFormat", "DateOutputFormat", "EnableUnloadPhysicalTypeOptimization", "ErrorOnNondeterministicMerge", "ErrorOnNondeterministicUpdate", "GeographyOutputFormat", "GeometryOutputFormat", "HybridTableLockTimeout", "JdbcTreatDecimalAsInt", "JdbcTreatTimestampNtzAsUtc", "JdbcUseSessionTimezone", "JsonIndent", "JsTreatIntegerAsBigInt", "LockTimeout", "LogLevel", "MultiStatementCount", "NoorderSequenceAsDefault", "OdbcTreatDecimalAsInt", "PythonProfilerModules", "PythonProfilerTargetStage", "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 } // ObjectParameters is based on https://docs.snowflake.com/en/sql-reference/parameters#object-parameters. type ObjectParameters struct { - Catalog *string `ddl:"parameter" sql:"CATALOG"` - DataRetentionTimeInDays *int `ddl:"parameter" sql:"DATA_RETENTION_TIME_IN_DAYS"` - DefaultDDLCollation *string `ddl:"parameter,single_quotes" sql:"DEFAULT_DDL_COLLATION"` - EnableUnredactedQuerySyntaxError *bool `ddl:"parameter" sql:"ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR"` - LogLevel *LogLevel `ddl:"parameter" sql:"LOG_LEVEL"` - MaxConcurrencyLevel *int `ddl:"parameter" sql:"MAX_CONCURRENCY_LEVEL"` - MaxDataExtensionTimeInDays *int `ddl:"parameter" sql:"MAX_DATA_EXTENSION_TIME_IN_DAYS"` - PipeExecutionPaused *bool `ddl:"parameter" sql:"PIPE_EXECUTION_PAUSED"` - PreventUnloadToInternalStages *bool `ddl:"parameter" sql:"PREVENT_UNLOAD_TO_INTERNAL_STAGES"` - StatementQueuedTimeoutInSeconds *int `ddl:"parameter" sql:"STATEMENT_QUEUED_TIMEOUT_IN_SECONDS"` - StatementTimeoutInSeconds *int `ddl:"parameter" sql:"STATEMENT_TIMEOUT_IN_SECONDS"` - NetworkPolicy *string `ddl:"parameter,single_quotes" sql:"NETWORK_POLICY"` - ShareRestrictions *bool `ddl:"parameter" sql:"SHARE_RESTRICTIONS"` - SuspendTaskAfterNumFailures *int `ddl:"parameter" sql:"SUSPEND_TASK_AFTER_NUM_FAILURES"` - TraceLevel *TraceLevel `ddl:"parameter" sql:"TRACE_LEVEL"` - UserTaskManagedInitialWarehouseSize *WarehouseSize `ddl:"parameter" sql:"USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE"` - UserTaskTimeoutMs *int `ddl:"parameter" sql:"USER_TASK_TIMEOUT_MS"` + Catalog *string `ddl:"parameter" sql:"CATALOG"` + DataRetentionTimeInDays *int `ddl:"parameter" sql:"DATA_RETENTION_TIME_IN_DAYS"` + DefaultDDLCollation *string `ddl:"parameter,single_quotes" sql:"DEFAULT_DDL_COLLATION"` + EnableUnredactedQuerySyntaxError *bool `ddl:"parameter" sql:"ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR"` + LogLevel *LogLevel `ddl:"parameter" sql:"LOG_LEVEL"` + MaxConcurrencyLevel *int `ddl:"parameter" sql:"MAX_CONCURRENCY_LEVEL"` + MaxDataExtensionTimeInDays *int `ddl:"parameter" sql:"MAX_DATA_EXTENSION_TIME_IN_DAYS"` + PipeExecutionPaused *bool `ddl:"parameter" sql:"PIPE_EXECUTION_PAUSED"` + PreventUnloadToInternalStages *bool `ddl:"parameter" sql:"PREVENT_UNLOAD_TO_INTERNAL_STAGES"` + StatementQueuedTimeoutInSeconds *int `ddl:"parameter" sql:"STATEMENT_QUEUED_TIMEOUT_IN_SECONDS"` + StatementTimeoutInSeconds *int `ddl:"parameter" sql:"STATEMENT_TIMEOUT_IN_SECONDS"` + NetworkPolicy *string `ddl:"parameter,single_quotes" sql:"NETWORK_POLICY"` + ShareRestrictions *bool `ddl:"parameter" sql:"SHARE_RESTRICTIONS"` + SuspendTaskAfterNumFailures *int `ddl:"parameter" sql:"SUSPEND_TASK_AFTER_NUM_FAILURES"` + StorageSerializationPolicy *string `ddl:"parameter" sql:"STORAGE_SERIALIZATION_POLICY"` + TraceLevel *TraceLevel `ddl:"parameter" sql:"TRACE_LEVEL"` + TaskAutoRetryAttempts *int `ddl:"parameter" sql:"TASK_AUTO_RETRY_ATTEMPTS"` + UserTaskManagedInitialWarehouseSize *WarehouseSize `ddl:"parameter" sql:"USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE"` + UserTaskMinimumTriggerIntervalInSeconds *int `ddl:"parameter" sql:"USER_TASK_MINIMUM_TRIGGER_INTERVAL_IN_SECONDS"` + UserTaskTimeoutMs *int `ddl:"parameter" sql:"USER_TASK_TIMEOUT_MS"` } func (v *ObjectParameters) validate() error { var errs []error if valueSet(v.DataRetentionTimeInDays) { - if !validateIntInRange(*v.DataRetentionTimeInDays, 0, 90) { + if !validateIntInRangeInclusive(*v.DataRetentionTimeInDays, 0, 90) { errs = append(errs, errIntBetween("ObjectParameters", "DataRetentionTimeInDays", 0, 90)) } } @@ -1544,7 +1686,7 @@ func (v *ObjectParameters) validate() error { } } if valueSet(v.MaxDataExtensionTimeInDays) { - if !validateIntInRange(*v.MaxDataExtensionTimeInDays, 0, 90) { + if !validateIntInRangeInclusive(*v.MaxDataExtensionTimeInDays, 0, 90) { errs = append(errs, errIntBetween("ObjectParameters", "MaxDataExtensionTimeInDays", 0, 90)) } } @@ -1563,9 +1705,19 @@ func (v *ObjectParameters) validate() error { errs = append(errs, errIntValue("ObjectParameters", "SuspendTaskAfterNumFailures", IntErrGreaterOrEqual, 0)) } } + if valueSet(v.TaskAutoRetryAttempts) { + if !validateIntGreaterThanOrEqual(*v.TaskAutoRetryAttempts, 0) { + errs = append(errs, errIntValue("ObjectParameters", "SuspendTaskAfterNumFailures", IntErrGreaterOrEqual, 0)) + } + } + if valueSet(v.UserTaskMinimumTriggerIntervalInSeconds) { + if !validateIntGreaterThanOrEqual(*v.UserTaskMinimumTriggerIntervalInSeconds, 0) { + errs = append(errs, errIntValue("ObjectParameters", "UserTaskMinimumTriggerIntervalInSeconds", IntErrGreaterOrEqual, 0)) + } + } if valueSet(v.UserTaskTimeoutMs) { - if !validateIntInRange(*v.UserTaskTimeoutMs, 0, 86400000) { - errs = append(errs, errIntBetween("ObjectParameters", "UserTaskTimeoutMs", 0, 86400000)) + if !validateIntGreaterThanOrEqual(*v.UserTaskTimeoutMs, 0) { + errs = append(errs, errIntValue("ObjectParameters", "UserTaskTimeoutMs", IntErrGreaterOrEqual, 0)) } } return errors.Join(errs...) @@ -1586,6 +1738,8 @@ type ObjectParametersUnset struct { NetworkPolicy *bool `ddl:"keyword" sql:"NETWORK_POLICY"` ShareRestrictions *bool `ddl:"keyword" sql:"SHARE_RESTRICTIONS"` SuspendTaskAfterNumFailures *bool `ddl:"keyword" sql:"SUSPEND_TASK_AFTER_NUM_FAILURES"` + StorageSerializationPolicy *bool `ddl:"keyword" sql:"STORAGE_SERIALIZATION_POLICY"` + TaskAutoRetryAttempts *bool `ddl:"keyword" sql:"TASK_AUTO_RETRY_ATTEMPTS"` TraceLevel *bool `ddl:"keyword" sql:"TRACE_LEVEL"` UserTaskManagedInitialWarehouseSize *bool `ddl:"keyword" sql:"USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE"` UserTaskTimeoutMs *bool `ddl:"keyword" sql:"USER_TASK_TIMEOUT_MS"` diff --git a/pkg/sdk/parameters_impl.go b/pkg/sdk/parameters_impl.go index d01af6d161..80600f292e 100644 --- a/pkg/sdk/parameters_impl.go +++ b/pkg/sdk/parameters_impl.go @@ -27,12 +27,16 @@ func (sessionParameters *SessionParameters) setParam(parameter SessionParameter, switch parameter { case SessionParameterAbortDetachedQuery: err = setBooleanValue(parameter, value, &sessionParameters.AbortDetachedQuery) + case SessionParameterActivePythonProfiler: + sessionParameters.ActivePythonProfiler = Pointer(ActivePythonProfiler(value)) case SessionParameterAutocommit: err = setBooleanValue(parameter, value, &sessionParameters.Autocommit) case SessionParameterBinaryInputFormat: sessionParameters.BinaryInputFormat = Pointer(BinaryInputFormat(value)) case SessionParameterBinaryOutputFormat: sessionParameters.BinaryOutputFormat = Pointer(BinaryOutputFormat(value)) + case SessionParameterClientEnableLogInfoStatementParameters: + err = setBooleanValue(parameter, value, &sessionParameters.ClientEnableLogInfoStatementParameters) case SessionParameterClientMemoryLimit: err = setIntegerValue(parameter, value, &sessionParameters.ClientMemoryLimit) case SessionParameterClientMetadataRequestUseConnectionCtx: @@ -51,6 +55,8 @@ func (sessionParameters *SessionParameters) setParam(parameter SessionParameter, err = setIntegerValue(parameter, value, &sessionParameters.ClientSessionKeepAliveHeartbeatFrequency) case SessionParameterClientTimestampTypeMapping: sessionParameters.ClientTimestampTypeMapping = Pointer(ClientTimestampTypeMapping(value)) + case SessionParameterCsvTimestampFormat: + sessionParameters.CsvTimestampFormat = &value case SessionParameterDateInputFormat: sessionParameters.DateInputFormat = &value case SessionParameterDateOutputFormat: @@ -65,14 +71,18 @@ func (sessionParameters *SessionParameters) setParam(parameter SessionParameter, sessionParameters.GeographyOutputFormat = Pointer(GeographyOutputFormat(value)) case SessionParameterGeometryOutputFormat: sessionParameters.GeometryOutputFormat = Pointer(GeometryOutputFormat(value)) + case SessionParameterHybridTableLockTimeout: + err = setIntegerValue(parameter, value, &sessionParameters.HybridTableLockTimeout) 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: - err = setIntegerValue(parameter, value, &sessionParameters.JSONIndent) + case SessionParameterJsonIndent: + err = setIntegerValue(parameter, value, &sessionParameters.JsonIndent) + case SessionParameterJsTreatIntegerAsBigInt: + err = setBooleanValue(parameter, value, &sessionParameters.JsTreatIntegerAsBigInt) case SessionParameterLockTimeout: err = setIntegerValue(parameter, value, &sessionParameters.LockTimeout) case SessionParameterLogLevel: @@ -83,6 +93,10 @@ func (sessionParameters *SessionParameters) setParam(parameter SessionParameter, err = setBooleanValue(parameter, value, &sessionParameters.NoorderSequenceAsDefault) case SessionParameterOdbcTreatDecimalAsInt: err = setBooleanValue(parameter, value, &sessionParameters.OdbcTreatDecimalAsInt) + case SessionParameterPythonProfilerModules: + sessionParameters.PythonProfilerModules = &value + case SessionParameterPythonProfilerTargetStage: + sessionParameters.PythonProfilerTargetStage = &value case SessionParameterQueryTag: sessionParameters.QueryTag = &value case SessionParameterQuotedIdentifiersIgnoreCase: @@ -99,8 +113,8 @@ func (sessionParameters *SessionParameters) setParam(parameter SessionParameter, err = setIntegerValue(parameter, value, &sessionParameters.StatementQueuedTimeoutInSeconds) case SessionParameterStatementTimeoutInSeconds: err = setIntegerValue(parameter, value, &sessionParameters.StatementTimeoutInSeconds) - case SessionParameterStrictJSONOutput: - err = setBooleanValue(parameter, value, &sessionParameters.StrictJSONOutput) + case SessionParameterStrictJsonOutput: + err = setBooleanValue(parameter, value, &sessionParameters.StrictJsonOutput) case SessionParameterTimestampDayIsAlways24h: err = setBooleanValue(parameter, value, &sessionParameters.TimestampDayIsAlways24h) case SessionParameterTimestampInputFormat: @@ -177,12 +191,16 @@ func (sessionParametersUnset *SessionParametersUnset) setParam(parameter Session switch parameter { case SessionParameterAbortDetachedQuery: unsetField = &sessionParametersUnset.AbortDetachedQuery + case SessionParameterActivePythonProfiler: + unsetField = &sessionParametersUnset.ActivePythonProfiler case SessionParameterAutocommit: unsetField = &sessionParametersUnset.Autocommit case SessionParameterBinaryInputFormat: unsetField = &sessionParametersUnset.BinaryInputFormat case SessionParameterBinaryOutputFormat: unsetField = &sessionParametersUnset.BinaryOutputFormat + case SessionParameterClientEnableLogInfoStatementParameters: + unsetField = &sessionParametersUnset.ClientEnableLogInfoStatementParameters case SessionParameterClientMemoryLimit: unsetField = &sessionParametersUnset.ClientMemoryLimit case SessionParameterClientMetadataRequestUseConnectionCtx: @@ -201,6 +219,8 @@ func (sessionParametersUnset *SessionParametersUnset) setParam(parameter Session unsetField = &sessionParametersUnset.ClientSessionKeepAliveHeartbeatFrequency case SessionParameterClientTimestampTypeMapping: unsetField = &sessionParametersUnset.ClientTimestampTypeMapping + case SessionParameterCsvTimestampFormat: + unsetField = &sessionParametersUnset.CsvTimestampFormat case SessionParameterDateInputFormat: unsetField = &sessionParametersUnset.DateInputFormat case SessionParameterDateOutputFormat: @@ -215,14 +235,18 @@ func (sessionParametersUnset *SessionParametersUnset) setParam(parameter Session unsetField = &sessionParametersUnset.GeographyOutputFormat case SessionParameterGeometryOutputFormat: unsetField = &sessionParametersUnset.GeometryOutputFormat + case SessionParameterHybridTableLockTimeout: + unsetField = &sessionParametersUnset.HybridTableLockTimeout case SessionParameterJdbcTreatDecimalAsInt: unsetField = &sessionParametersUnset.JdbcTreatDecimalAsInt case SessionParameterJdbcTreatTimestampNtzAsUtc: unsetField = &sessionParametersUnset.JdbcTreatTimestampNtzAsUtc case SessionParameterJdbcUseSessionTimezone: unsetField = &sessionParametersUnset.JdbcUseSessionTimezone - case SessionParameterJSONIndent: - unsetField = &sessionParametersUnset.JSONIndent + case SessionParameterJsonIndent: + unsetField = &sessionParametersUnset.JsonIndent + case SessionParameterJsTreatIntegerAsBigInt: + unsetField = &sessionParametersUnset.JsTreatIntegerAsBigInt case SessionParameterLockTimeout: unsetField = &sessionParametersUnset.LockTimeout case SessionParameterLogLevel: @@ -233,6 +257,10 @@ func (sessionParametersUnset *SessionParametersUnset) setParam(parameter Session unsetField = &sessionParametersUnset.NoorderSequenceAsDefault case SessionParameterOdbcTreatDecimalAsInt: unsetField = &sessionParametersUnset.OdbcTreatDecimalAsInt + case SessionParameterPythonProfilerModules: + unsetField = &sessionParametersUnset.PythonProfilerModules + case SessionParameterPythonProfilerTargetStage: + unsetField = &sessionParametersUnset.PythonProfilerTargetStage case SessionParameterQueryTag: unsetField = &sessionParametersUnset.QueryTag case SessionParameterQuotedIdentifiersIgnoreCase: @@ -249,8 +277,8 @@ func (sessionParametersUnset *SessionParametersUnset) setParam(parameter Session unsetField = &sessionParametersUnset.StatementQueuedTimeoutInSeconds case SessionParameterStatementTimeoutInSeconds: unsetField = &sessionParametersUnset.StatementTimeoutInSeconds - case SessionParameterStrictJSONOutput: - unsetField = &sessionParametersUnset.StrictJSONOutput + case SessionParameterStrictJsonOutput: + unsetField = &sessionParametersUnset.StrictJsonOutput case SessionParameterTimestampDayIsAlways24h: unsetField = &sessionParametersUnset.TimestampDayIsAlways24h case SessionParameterTimestampInputFormat: diff --git a/pkg/sdk/parameters_impl_test.go b/pkg/sdk/parameters_impl_test.go index d235a42a5e..b8859154d2 100644 --- a/pkg/sdk/parameters_impl_test.go +++ b/pkg/sdk/parameters_impl_test.go @@ -15,9 +15,11 @@ func TestSessionParameters_setParam(t *testing.T) { accessor func(*SessionParameters) any }{ {parameter: SessionParameterAbortDetachedQuery, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.AbortDetachedQuery }}, + {parameter: SessionParameterActivePythonProfiler, value: "LINE", expectedValue: ActivePythonProfilerLine, accessor: func(sp *SessionParameters) any { return *sp.ActivePythonProfiler }}, {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: SessionParameterClientEnableLogInfoStatementParameters, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.ClientEnableLogInfoStatementParameters }}, {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: SessionParameterClientPrefetchThreads, value: "1", expectedValue: 1, accessor: func(sp *SessionParameters) any { return *sp.ClientPrefetchThreads }}, @@ -27,6 +29,7 @@ func TestSessionParameters_setParam(t *testing.T) { {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: SessionParameterCsvTimestampFormat, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.CsvTimestampFormat }}, {parameter: SessionParameterDateInputFormat, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.DateInputFormat }}, {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 }}, @@ -34,15 +37,19 @@ func TestSessionParameters_setParam(t *testing.T) { {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: SessionParameterHybridTableLockTimeout, value: "1", expectedValue: 1, accessor: func(sp *SessionParameters) any { return *sp.HybridTableLockTimeout }}, {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: SessionParameterJsonIndent, value: "1", expectedValue: 1, accessor: func(sp *SessionParameters) any { return *sp.JsonIndent }}, + {parameter: SessionParameterJsTreatIntegerAsBigInt, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.JsTreatIntegerAsBigInt }}, {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: SessionParameterPythonProfilerModules, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.PythonProfilerModules }}, + {parameter: SessionParameterPythonProfilerTargetStage, value: "some", expectedValue: "some", accessor: func(sp *SessionParameters) any { return *sp.PythonProfilerTargetStage }}, {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 }}, @@ -51,7 +58,7 @@ func TestSessionParameters_setParam(t *testing.T) { {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: SessionParameterStrictJsonOutput, value: "true", expectedValue: true, accessor: func(sp *SessionParameters) any { return *sp.StrictJsonOutput }}, {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 }}, @@ -98,7 +105,7 @@ func TestSessionParameters_setParam(t *testing.T) { // {parameter: SessionParameterDateOutputFormat, value: "some"}, // add validation {parameter: SessionParameterErrorOnNondeterministicMerge, value: "true123"}, {parameter: SessionParameterErrorOnNondeterministicUpdate, value: "true123"}, - {parameter: SessionParameterJSONIndent, value: "aaa"}, + {parameter: SessionParameterJsonIndent, value: "aaa"}, {parameter: SessionParameterLockTimeout, value: "aaa"}, {parameter: SessionParameterMultiStatementCount, value: "aaa"}, // {parameter: SessionParameterQueryTag, value: "some"}, // add validation @@ -106,7 +113,7 @@ func TestSessionParameters_setParam(t *testing.T) { {parameter: SessionParameterRowsPerResultset, value: "aaa"}, // {parameter: SessionParameterSimulatedDataSharingConsumer, value: "some"}, // add validation {parameter: SessionParameterStatementTimeoutInSeconds, value: "aaa"}, - {parameter: SessionParameterStrictJSONOutput, value: "true123"}, + {parameter: SessionParameterStrictJsonOutput, value: "true123"}, // {parameter: SessionParameterTimeInputFormat, value: "some"}, // add validation // {parameter: SessionParameterTimeOutputFormat, value: "some"}, // add validation {parameter: SessionParameterTimestampDayIsAlways24h, value: "true123"}, diff --git a/pkg/sdk/parameters_test.go b/pkg/sdk/parameters_test.go index a288f9eee5..93592e1f1e 100644 --- a/pkg/sdk/parameters_test.go +++ b/pkg/sdk/parameters_test.go @@ -68,10 +68,13 @@ func TestToAccountParameter(t *testing.T) { {input: "ALLOW_CLIENT_MFA_CACHING", want: AccountParameterAllowClientMFACaching}, {input: "ALLOW_ID_TOKEN", want: AccountParameterAllowIDToken}, {input: "CLIENT_ENCRYPTION_KEY_SIZE", want: AccountParameterClientEncryptionKeySize}, + {input: "CORTEX_ENABLED_CROSS_REGION", want: AccountParameterCortexEnabledCrossRegion}, {input: "ENABLE_IDENTIFIER_FIRST_LOGIN", want: AccountParameterEnableIdentifierFirstLogin}, {input: "ENABLE_INTERNAL_STAGES_PRIVATELINK", want: AccountParameterEnableInternalStagesPrivatelink}, {input: "ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_IMAGE_REPOSITORY", want: AccountParameterEnableTriSecretAndRekeyOptOutForImageRepository}, {input: "ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_SPCS_BLOCK_STORAGE", want: AccountParameterEnableTriSecretAndRekeyOptOutForSpcsBlockStorage}, + {input: "ENABLE_UNHANDLED_EXCEPTIONS_REPORTING", want: AccountParameterEnableUnhandledExceptionsReporting}, + {input: "ENFORCE_NETWORK_RULES_FOR_INTERNAL_STAGES", want: AccountParameterEnforceNetworkRulesForInternalStages}, {input: "EVENT_TABLE", want: AccountParameterEventTable}, {input: "EXTERNAL_OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST", want: AccountParameterExternalOAuthAddPrivilegedRolesToBlockedList}, {input: "INITIAL_REPLICATION_SIZE_LIMIT_IN_TB", want: AccountParameterInitialReplicationSizeLimitInTB}, @@ -81,32 +84,53 @@ func TestToAccountParameter(t *testing.T) { {input: "PERIODIC_DATA_REKEYING", want: AccountParameterPeriodicDataRekeying}, {input: "PREVENT_LOAD_FROM_INLINE_URL", want: AccountParameterPreventLoadFromInlineURL}, {input: "PREVENT_UNLOAD_TO_INLINE_URL", want: AccountParameterPreventUnloadToInlineURL}, - {input: "PREVENT_UNLOAD_TO_INTERNAL_STAGES", want: AccountParameterPreventUnloadToInternalStages}, {input: "REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION", want: AccountParameterRequireStorageIntegrationForStageCreation}, {input: "REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_OPERATION", want: AccountParameterRequireStorageIntegrationForStageOperation}, {input: "SSO_LOGIN_PAGE", want: AccountParameterSSOLoginPage}, + + // Session Parameters (inherited) {input: "ABORT_DETACHED_QUERY", want: AccountParameterAbortDetachedQuery}, + {input: "ACTIVE_PYTHON_PROFILER", want: AccountParameterActivePythonProfiler}, {input: "AUTOCOMMIT", want: AccountParameterAutocommit}, {input: "BINARY_INPUT_FORMAT", want: AccountParameterBinaryInputFormat}, {input: "BINARY_OUTPUT_FORMAT", want: AccountParameterBinaryOutputFormat}, + {input: "CLIENT_ENABLE_LOG_INFO_STATEMENT_PARAMETERS", want: AccountParameterClientEnableLogInfoStatementParameters}, + {input: "CLIENT_MEMORY_LIMIT", want: AccountParameterClientMemoryLimit}, {input: "CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX", want: AccountParameterClientMetadataRequestUseConnectionCtx}, {input: "CLIENT_METADATA_USE_SESSION_DATABASE", want: AccountParameterClientMetadataUseSessionDatabase}, + {input: "CLIENT_PREFETCH_THREADS", want: AccountParameterClientPrefetchThreads}, + {input: "CLIENT_RESULT_CHUNK_SIZE", want: AccountParameterClientResultChunkSize}, {input: "CLIENT_RESULT_COLUMN_CASE_INSENSITIVE", want: AccountParameterClientResultColumnCaseInsensitive}, + {input: "CLIENT_SESSION_KEEP_ALIVE", want: AccountParameterClientSessionKeepAlive}, + {input: "CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY", want: AccountParameterClientSessionKeepAliveHeartbeatFrequency}, + {input: "CLIENT_TIMESTAMP_TYPE_MAPPING", want: AccountParameterClientTimestampTypeMapping}, + {input: "CSV_TIMESTAMP_FORMAT", want: AccountParameterCsvTimestampFormat}, {input: "DATE_INPUT_FORMAT", want: AccountParameterDateInputFormat}, {input: "DATE_OUTPUT_FORMAT", want: AccountParameterDateOutputFormat}, + {input: "ENABLE_UNLOAD_PHYSICAL_TYPE_OPTIMIZATION", want: AccountParameterEnableUnloadPhysicalTypeOptimization}, {input: "ERROR_ON_NONDETERMINISTIC_MERGE", want: AccountParameterErrorOnNondeterministicMerge}, {input: "ERROR_ON_NONDETERMINISTIC_UPDATE", want: AccountParameterErrorOnNondeterministicUpdate}, {input: "GEOGRAPHY_OUTPUT_FORMAT", want: AccountParameterGeographyOutputFormat}, - {input: "JSON_INDENT", want: AccountParameterJSONIndent}, + {input: "GEOMETRY_OUTPUT_FORMAT", want: AccountParameterGeometryOutputFormat}, + {input: "HYBRID_TABLE_LOCK_TIMEOUT", want: AccountParameterHybridTableLockTimeout}, + {input: "JDBC_TREAT_DECIMAL_AS_INT", want: AccountParameterJdbcTreatDecimalAsInt}, + {input: "JDBC_TREAT_TIMESTAMP_NTZ_AS_UTC", want: AccountParameterJdbcTreatTimestampNtzAsUtc}, + {input: "JDBC_USE_SESSION_TIMEZONE", want: AccountParameterJdbcUseSessionTimezone}, + {input: "JSON_INDENT", want: AccountParameterJsonIndent}, + {input: "JS_TREAT_INTEGER_AS_BIGINT", want: AccountParameterJsTreatIntegerAsBigInt}, {input: "LOCK_TIMEOUT", want: AccountParameterLockTimeout}, {input: "MULTI_STATEMENT_COUNT", want: AccountParameterMultiStatementCount}, + {input: "NOORDER_SEQUENCE_AS_DEFAULT", want: AccountParameterNoorderSequenceAsDefault}, + {input: "ODBC_TREAT_DECIMAL_AS_INT", want: AccountParameterOdbcTreatDecimalAsInt}, + {input: "PYTHON_PROFILER_MODULES", want: AccountParameterPythonProfilerModules}, + {input: "PYTHON_PROFILER_TARGET_STAGE", want: AccountParameterPythonProfilerTargetStage}, {input: "QUERY_TAG", want: AccountParameterQueryTag}, {input: "QUOTED_IDENTIFIERS_IGNORE_CASE", want: AccountParameterQuotedIdentifiersIgnoreCase}, {input: "ROWS_PER_RESULTSET", want: AccountParameterRowsPerResultset}, {input: "S3_STAGE_VPCE_DNS_NAME", want: AccountParameterS3StageVpceDnsName}, + {input: "SEARCH_PATH", want: AccountParameterSearchPath}, {input: "SIMULATED_DATA_SHARING_CONSUMER", want: AccountParameterSimulatedDataSharingConsumer}, - {input: "STATEMENT_TIMEOUT_IN_SECONDS", want: AccountParameterStatementTimeoutInSeconds}, - {input: "STRICT_JSON_OUTPUT", want: AccountParameterStrictJSONOutput}, + {input: "STRICT_JSON_OUTPUT", want: AccountParameterStrictJsonOutput}, {input: "TIME_INPUT_FORMAT", want: AccountParameterTimeInputFormat}, {input: "TIME_OUTPUT_FORMAT", want: AccountParameterTimeOutputFormat}, {input: "TIMESTAMP_DAY_IS_ALWAYS_24H", want: AccountParameterTimestampDayIsAlways24h}, @@ -124,6 +148,8 @@ func TestToAccountParameter(t *testing.T) { {input: "USE_CACHED_RESULT", want: AccountParameterUseCachedResult}, {input: "WEEK_OF_YEAR_POLICY", want: AccountParameterWeekOfYearPolicy}, {input: "WEEK_START", want: AccountParameterWeekStart}, + + // Object Parameters (inherited) {input: "CATALOG", want: AccountParameterCatalog}, {input: "DATA_RETENTION_TIME_IN_DAYS", want: AccountParameterDataRetentionTimeInDays}, {input: "DEFAULT_DDL_COLLATION", want: AccountParameterDefaultDDLCollation}, @@ -134,6 +160,7 @@ func TestToAccountParameter(t *testing.T) { {input: "PIPE_EXECUTION_PAUSED", want: AccountParameterPipeExecutionPaused}, {input: "REPLACE_INVALID_CHARACTERS", want: AccountParameterReplaceInvalidCharacters}, {input: "STATEMENT_QUEUED_TIMEOUT_IN_SECONDS", want: AccountParameterStatementQueuedTimeoutInSeconds}, + {input: "STATEMENT_TIMEOUT_IN_SECONDS", want: AccountParameterStatementTimeoutInSeconds}, {input: "STORAGE_SERIALIZATION_POLICY", want: AccountParameterStorageSerializationPolicy}, {input: "SHARE_RESTRICTIONS", want: AccountParameterShareRestrictions}, {input: "SUSPEND_TASK_AFTER_NUM_FAILURES", want: AccountParameterSuspendTaskAfterNumFailures}, @@ -144,7 +171,11 @@ func TestToAccountParameter(t *testing.T) { {input: "USER_TASK_MINIMUM_TRIGGER_INTERVAL_IN_SECONDS", want: AccountParameterUserTaskMinimumTriggerIntervalInSeconds}, {input: "METRIC_LEVEL", want: AccountParameterMetricLevel}, {input: "ENABLE_CONSOLE_OUTPUT", want: AccountParameterEnableConsoleOutput}, + + // User Parameters (inherited) + {input: "ENABLE_PERSONAL_DATABASE", want: AccountParameterEnablePersonalDatabase}, {input: "ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR", want: AccountParameterEnableUnredactedQuerySyntaxError}, + {input: "PREVENT_UNLOAD_TO_INTERNAL_STAGES", want: AccountParameterPreventUnloadToInternalStages}, } invalid := []test{ diff --git a/pkg/sdk/tags_validations.go b/pkg/sdk/tags_validations.go index 25a219c533..2d01814df5 100644 --- a/pkg/sdk/tags_validations.go +++ b/pkg/sdk/tags_validations.go @@ -36,7 +36,7 @@ func (opts *createTagOptions) validate() error { } func (v *AllowedValues) validate() error { - if !validateIntInRange(len(v.Values), 1, 300) { + if !validateIntInRangeInclusive(len(v.Values), 1, 300) { return errIntBetween("AllowedValues", "Values", 1, 300) } return nil diff --git a/pkg/sdk/tasks_gen_test.go b/pkg/sdk/tasks_gen_test.go index 9422d73824..56b8fe4c6f 100644 --- a/pkg/sdk/tasks_gen_test.go +++ b/pkg/sdk/tasks_gen_test.go @@ -45,9 +45,9 @@ func TestTasks_Create(t *testing.T) { t.Run("validation: opts.SessionParameters.SessionParameters should be valid", func(t *testing.T) { opts := defaultOpts() opts.SessionParameters = &SessionParameters{ - JSONIndent: Int(25), + JsonIndent: Int(-1), } - assertOptsInvalidJoinedErrors(t, opts, errIntBetween("SessionParameters", "JSONIndent", 0, 16)) + assertOptsInvalidJoinedErrors(t, opts, errIntValue("SessionParameters", "JsonIndent", IntErrGreaterOrEqual, 0)) }) t.Run("basic", func(t *testing.T) { @@ -78,7 +78,7 @@ func TestTasks_Create(t *testing.T) { opts.Config = String(`$${"output_dir": "/temp/test_directory/", "learning_rate": 0.1}$$`) opts.AllowOverlappingExecution = Bool(true) opts.SessionParameters = &SessionParameters{ - JSONIndent: Int(10), + JsonIndent: Int(10), LockTimeout: Int(5), } opts.UserTaskTimeoutMs = Int(5) @@ -131,7 +131,7 @@ func TestTasks_CreateOrAlter(t *testing.T) { t.Run("validation: opts.SessionParameters.SessionParameters should be valid", func(t *testing.T) { opts := defaultOpts() opts.SessionParameters = &SessionParameters{ - JSONIndent: Int(25), + JsonIndent: Int(25), } assertOptsInvalidJoinedErrors(t, opts, errIntBetween("SessionParameters", "JSONIndent", 0, 16)) }) @@ -155,7 +155,7 @@ func TestTasks_CreateOrAlter(t *testing.T) { opts.AllowOverlappingExecution = Bool(true) opts.UserTaskTimeoutMs = Int(5) opts.SessionParameters = &SessionParameters{ - JSONIndent: Int(10), + JsonIndent: Int(10), LockTimeout: Int(5), } opts.SuspendTaskAfterNumFailures = Int(6) @@ -265,7 +265,7 @@ func TestTasks_Alter(t *testing.T) { opts := defaultOpts() opts.Set = &TaskSet{} opts.Set.SessionParameters = &SessionParameters{ - JSONIndent: Int(25), + JsonIndent: Int(25), } assertOptsInvalidJoinedErrors(t, opts, errIntBetween("SessionParameters", "JSONIndent", 0, 16)) }) @@ -337,7 +337,7 @@ func TestTasks_Alter(t *testing.T) { opts := defaultOpts() opts.Set = &TaskSet{ SessionParameters: &SessionParameters{ - JSONIndent: Int(15), + JsonIndent: Int(15), }, } assertOptsValidAndSQLEquals(t, opts, "ALTER TASK %s SET JSON_INDENT = 15", id.FullyQualifiedName()) diff --git a/pkg/sdk/testint/accounts_integration_test.go b/pkg/sdk/testint/accounts_integration_test.go index 6ed6b1ac5d..f2e646073d 100644 --- a/pkg/sdk/testint/accounts_integration_test.go +++ b/pkg/sdk/testint/accounts_integration_test.go @@ -457,7 +457,7 @@ func TestInt_Account_SelfAlter(t *testing.T) { require.NotEmpty(t, parameters) assertParameterIsDefault(t, parameters, string(sdk.AccountParameterMinDataRetentionTimeInDays)) - assertParameterIsDefault(t, parameters, string(sdk.AccountParameterJSONIndent)) + assertParameterIsDefault(t, parameters, string(sdk.AccountParameterJsonIndent)) assertParameterIsDefault(t, parameters, string(sdk.AccountParameterUserTaskTimeoutMs)) assertParameterIsDefault(t, parameters, string(sdk.AccountParameterEnableUnredactedQuerySyntaxError)) @@ -468,7 +468,7 @@ func TestInt_Account_SelfAlter(t *testing.T) { MinDataRetentionTimeInDays: sdk.Int(15), // default is 0 }, SessionParameters: &sdk.SessionParameters{ - JSONIndent: sdk.Int(8), // default is 2 + JsonIndent: sdk.Int(8), // default is 2 }, ObjectParameters: &sdk.ObjectParameters{ UserTaskTimeoutMs: sdk.Int(100), // default is 3600000 @@ -486,7 +486,7 @@ func TestInt_Account_SelfAlter(t *testing.T) { require.NotEmpty(t, parameters) assertParameterValueSetOnAccount(t, parameters, string(sdk.AccountParameterMinDataRetentionTimeInDays), "15") - assertParameterValueSetOnAccount(t, parameters, string(sdk.AccountParameterJSONIndent), "8") + assertParameterValueSetOnAccount(t, parameters, string(sdk.AccountParameterJsonIndent), "8") assertParameterValueSetOnAccount(t, parameters, string(sdk.AccountParameterUserTaskTimeoutMs), "100") assertParameterValueSetOnAccount(t, parameters, string(sdk.AccountParameterEnableUnredactedQuerySyntaxError), "true") @@ -497,7 +497,7 @@ func TestInt_Account_SelfAlter(t *testing.T) { MinDataRetentionTimeInDays: sdk.Bool(true), }, SessionParameters: &sdk.SessionParametersUnset{ - JSONIndent: sdk.Bool(true), + JsonIndent: sdk.Bool(true), }, ObjectParameters: &sdk.ObjectParametersUnset{ UserTaskTimeoutMs: sdk.Bool(true), @@ -515,7 +515,7 @@ func TestInt_Account_SelfAlter(t *testing.T) { require.NotEmpty(t, parameters) assertParameterIsDefault(t, parameters, string(sdk.AccountParameterMinDataRetentionTimeInDays)) - assertParameterIsDefault(t, parameters, string(sdk.AccountParameterJSONIndent)) + assertParameterIsDefault(t, parameters, string(sdk.AccountParameterJsonIndent)) assertParameterIsDefault(t, parameters, string(sdk.AccountParameterUserTaskTimeoutMs)) assertParameterIsDefault(t, parameters, string(sdk.AccountParameterEnableUnredactedQuerySyntaxError)) }) diff --git a/pkg/sdk/testint/tasks_gen_integration_test.go b/pkg/sdk/testint/tasks_gen_integration_test.go index 6304a830d4..5efdade6de 100644 --- a/pkg/sdk/testint/tasks_gen_integration_test.go +++ b/pkg/sdk/testint/tasks_gen_integration_test.go @@ -142,7 +142,7 @@ func TestInt_Tasks(t *testing.T) { GeometryOutputFormat: sdk.Pointer(sdk.GeometryOutputFormatWKB), JdbcTreatTimestampNtzAsUtc: sdk.Bool(true), JdbcUseSessionTimezone: sdk.Bool(false), - JSONIndent: sdk.Int(4), + JsonIndent: sdk.Int(4), LockTimeout: sdk.Int(21222), LogLevel: sdk.Pointer(sdk.LogLevelError), MultiStatementCount: sdk.Int(0), @@ -155,7 +155,7 @@ func TestInt_Tasks(t *testing.T) { SearchPath: sdk.String("$public, $current"), StatementQueuedTimeoutInSeconds: sdk.Int(10), StatementTimeoutInSeconds: sdk.Int(10), - StrictJSONOutput: sdk.Bool(true), + StrictJsonOutput: sdk.Bool(true), TimestampDayIsAlways24h: sdk.Bool(true), TimestampInputFormat: sdk.String("YYYY-MM-DD"), TimestampLTZOutputFormat: sdk.String("YYYY-MM-DD HH24:MI:SS"), @@ -276,7 +276,7 @@ func TestInt_Tasks(t *testing.T) { WithConfig(`{"output_dir": "/temp/test_directory/", "learning_rate": 0.1}`). WithAllowOverlappingExecution(true). WithSessionParameters(sdk.SessionParameters{ - JSONIndent: sdk.Int(4), + JsonIndent: sdk.Int(4), }). WithUserTaskTimeoutMs(500). WithSuspendTaskAfterNumFailures(3). @@ -667,7 +667,7 @@ func TestInt_Tasks(t *testing.T) { GeometryOutputFormat: sdk.Bool(true), JdbcTreatTimestampNtzAsUtc: sdk.Bool(true), JdbcUseSessionTimezone: sdk.Bool(true), - JSONIndent: sdk.Bool(true), + JsonIndent: sdk.Bool(true), LockTimeout: sdk.Bool(true), LogLevel: sdk.Bool(true), MultiStatementCount: sdk.Bool(true), @@ -680,7 +680,7 @@ func TestInt_Tasks(t *testing.T) { SearchPath: sdk.Bool(true), StatementQueuedTimeoutInSeconds: sdk.Bool(true), StatementTimeoutInSeconds: sdk.Bool(true), - StrictJSONOutput: sdk.Bool(true), + StrictJsonOutput: sdk.Bool(true), TimestampDayIsAlways24h: sdk.Bool(true), TimestampInputFormat: sdk.Bool(true), TimestampLTZOutputFormat: sdk.Bool(true), diff --git a/pkg/sdk/testint/users_integration_test.go b/pkg/sdk/testint/users_integration_test.go index 87dc57819a..cc884d6cc8 100644 --- a/pkg/sdk/testint/users_integration_test.go +++ b/pkg/sdk/testint/users_integration_test.go @@ -774,7 +774,7 @@ func TestInt_Users(t *testing.T) { JdbcTreatDecimalAsInt: sdk.Bool(false), JdbcTreatTimestampNtzAsUtc: sdk.Bool(true), JdbcUseSessionTimezone: sdk.Bool(false), - JSONIndent: sdk.Int(4), + JsonIndent: sdk.Int(4), LockTimeout: sdk.Int(21222), LogLevel: sdk.Pointer(sdk.LogLevelError), MultiStatementCount: sdk.Int(0), @@ -788,7 +788,7 @@ func TestInt_Users(t *testing.T) { SimulatedDataSharingConsumer: sdk.String("some_consumer"), StatementQueuedTimeoutInSeconds: sdk.Int(10), StatementTimeoutInSeconds: sdk.Int(10), - StrictJSONOutput: sdk.Bool(true), + StrictJsonOutput: sdk.Bool(true), TimestampDayIsAlways24h: sdk.Bool(true), TimestampInputFormat: sdk.String("YYYY-MM-DD"), TimestampLTZOutputFormat: sdk.String("YYYY-MM-DD HH24:MI:SS"), @@ -1406,7 +1406,7 @@ func TestInt_Users(t *testing.T) { JdbcTreatDecimalAsInt: sdk.Bool(false), JdbcTreatTimestampNtzAsUtc: sdk.Bool(true), JdbcUseSessionTimezone: sdk.Bool(false), - JSONIndent: sdk.Int(4), + JsonIndent: sdk.Int(4), LockTimeout: sdk.Int(21222), LogLevel: sdk.Pointer(sdk.LogLevelError), MultiStatementCount: sdk.Int(0), @@ -1420,7 +1420,7 @@ func TestInt_Users(t *testing.T) { SimulatedDataSharingConsumer: sdk.String("some_consumer"), StatementQueuedTimeoutInSeconds: sdk.Int(10), StatementTimeoutInSeconds: sdk.Int(10), - StrictJSONOutput: sdk.Bool(true), + StrictJsonOutput: sdk.Bool(true), TimestampDayIsAlways24h: sdk.Bool(true), TimestampInputFormat: sdk.String("YYYY-MM-DD"), TimestampLTZOutputFormat: sdk.String("YYYY-MM-DD HH24:MI:SS"), @@ -1483,7 +1483,7 @@ func TestInt_Users(t *testing.T) { JdbcTreatDecimalAsInt: sdk.Bool(true), JdbcTreatTimestampNtzAsUtc: sdk.Bool(true), JdbcUseSessionTimezone: sdk.Bool(true), - JSONIndent: sdk.Bool(true), + JsonIndent: sdk.Bool(true), LockTimeout: sdk.Bool(true), LogLevel: sdk.Bool(true), MultiStatementCount: sdk.Bool(true), @@ -1497,7 +1497,7 @@ func TestInt_Users(t *testing.T) { SimulatedDataSharingConsumer: sdk.Bool(true), StatementQueuedTimeoutInSeconds: sdk.Bool(true), StatementTimeoutInSeconds: sdk.Bool(true), - StrictJSONOutput: sdk.Bool(true), + StrictJsonOutput: sdk.Bool(true), TimestampDayIsAlways24h: sdk.Bool(true), TimestampInputFormat: sdk.Bool(true), TimestampLTZOutputFormat: sdk.Bool(true), @@ -1732,7 +1732,7 @@ func TestInt_Users(t *testing.T) { JdbcTreatDecimalAsInt: sdk.Bool(false), JdbcTreatTimestampNtzAsUtc: sdk.Bool(true), JdbcUseSessionTimezone: sdk.Bool(false), - JSONIndent: sdk.Int(4), + JsonIndent: sdk.Int(4), LockTimeout: sdk.Int(21222), LogLevel: sdk.Pointer(sdk.LogLevelError), MultiStatementCount: sdk.Int(0), @@ -1746,7 +1746,7 @@ func TestInt_Users(t *testing.T) { SimulatedDataSharingConsumer: sdk.String("some_consumer"), StatementQueuedTimeoutInSeconds: sdk.Int(10), StatementTimeoutInSeconds: sdk.Int(10), - StrictJSONOutput: sdk.Bool(true), + StrictJsonOutput: sdk.Bool(true), TimestampDayIsAlways24h: sdk.Bool(true), TimestampInputFormat: sdk.String("YYYY-MM-DD"), TimestampLTZOutputFormat: sdk.String("YYYY-MM-DD HH24:MI:SS"), diff --git a/pkg/sdk/validations.go b/pkg/sdk/validations.go index d8199f2d24..aee936e17a 100644 --- a/pkg/sdk/validations.go +++ b/pkg/sdk/validations.go @@ -89,7 +89,7 @@ func valueSet(value interface{}) bool { return true } -func validateIntInRange(value int, min int, max int) bool { +func validateIntInRangeInclusive(value int, min int, max int) bool { if value < min || value > max { return false } diff --git a/pkg/sdk/validations_test.go b/pkg/sdk/validations_test.go index 36d26c0470..f9661d50aa 100644 --- a/pkg/sdk/validations_test.go +++ b/pkg/sdk/validations_test.go @@ -168,14 +168,14 @@ func TestValueSet(t *testing.T) { }) } -func TestValidateIntInRange(t *testing.T) { +func TestValidateIntInRangeInclusive(t *testing.T) { t.Run("with value in range", func(t *testing.T) { - ok := validateIntInRange(5, 0, 10) + ok := validateIntInRangeInclusive(5, 0, 10) assert.Equal(t, ok, true) }) t.Run("with value out of range", func(t *testing.T) { - ok := validateIntInRange(5, 10, 20) + ok := validateIntInRangeInclusive(5, 10, 20) assert.Equal(t, ok, false) }) } diff --git a/pkg/sdk/warehouses.go b/pkg/sdk/warehouses.go index e9799f74dc..d0970687ee 100644 --- a/pkg/sdk/warehouses.go +++ b/pkg/sdk/warehouses.go @@ -155,7 +155,7 @@ func (opts *CreateWarehouseOptions) validate() error { if valueSet(opts.MinClusterCount) && valueSet(opts.MaxClusterCount) && !validateIntGreaterThanOrEqual(*opts.MaxClusterCount, *opts.MinClusterCount) { errs = append(errs, fmt.Errorf("MinClusterCount must be less than or equal to MaxClusterCount")) } - if valueSet(opts.QueryAccelerationMaxScaleFactor) && !validateIntInRange(*opts.QueryAccelerationMaxScaleFactor, 0, 100) { + if valueSet(opts.QueryAccelerationMaxScaleFactor) && !validateIntInRangeInclusive(*opts.QueryAccelerationMaxScaleFactor, 0, 100) { errs = append(errs, errIntBetween("CreateWarehouseOptions", "QueryAccelerationMaxScaleFactor", 0, 100)) } return errors.Join(errs...) @@ -250,7 +250,7 @@ type WarehouseSet struct { func (v *WarehouseSet) validate() error { // we validate only the case then both are set together, if only MinClusterCount is set, we leave it for Snowflake to validate if v.MinClusterCount != nil && valueSet(v.MaxClusterCount) { - if ok := validateIntInRange(*v.MinClusterCount, 1, *v.MaxClusterCount); !ok { + if ok := validateIntInRangeInclusive(*v.MinClusterCount, 1, *v.MaxClusterCount); !ok { return fmt.Errorf("MinClusterCount must be less than or equal to MaxClusterCount") } } @@ -260,7 +260,7 @@ func (v *WarehouseSet) validate() error { } } if v.QueryAccelerationMaxScaleFactor != nil { - if ok := validateIntInRange(*v.QueryAccelerationMaxScaleFactor, 0, 100); !ok { + if ok := validateIntInRangeInclusive(*v.QueryAccelerationMaxScaleFactor, 0, 100); !ok { return fmt.Errorf("QueryAccelerationMaxScaleFactor must be between 0 and 100") } }