From 0050f449b3ef46d5db49c5e87e3a7d8a1aac95a9 Mon Sep 17 00:00:00 2001 From: Jakub Michalak Date: Fri, 20 Dec 2024 10:14:10 +0100 Subject: [PATCH] Add missing --- pkg/resources/task_parameters.go | 8 +- pkg/resources/user_parameters.go | 8 +- pkg/sdk/accounts_test.go | 2 +- pkg/sdk/parameters.go | 178 ++++++++++++------ pkg/sdk/parameters_impl.go | 20 +- pkg/sdk/parameters_impl_test.go | 9 +- pkg/sdk/parameters_test.go | 5 +- pkg/sdk/tags_validations.go | 2 +- pkg/sdk/tasks_gen_test.go | 12 +- 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 | 4 +- pkg/sdk/warehouses.go | 6 +- 15 files changed, 181 insertions(+), 111 deletions(-) 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 9aefdc0aa0..1971b7623a 100644 --- a/pkg/sdk/parameters.go +++ b/pkg/sdk/parameters.go @@ -318,7 +318,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: @@ -328,13 +328,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: @@ -352,13 +352,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: @@ -369,12 +369,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: @@ -382,7 +390,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: @@ -430,8 +438,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: @@ -534,6 +546,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" @@ -545,7 +558,7 @@ const ( 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" @@ -559,7 +572,7 @@ const ( AccountParameterS3StageVpceDnsName AccountParameter = "S3_STAGE_VPCE_DNS_NAME" AccountParameterSearchPath AccountParameter = "SEARCH_PATH" AccountParameterSimulatedDataSharingConsumer AccountParameter = "SIMULATED_DATA_SHARING_CONSUMER" - 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" @@ -647,6 +660,7 @@ var AllAccountParameters = []AccountParameter{ AccountParameterClientTimestampTypeMapping, AccountParameterEnableUnloadPhysicalTypeOptimization, AccountParameterClientResultColumnCaseInsensitive, + AccountParameterCsvTimestampFormat, AccountParameterDateInputFormat, AccountParameterDateOutputFormat, AccountParameterErrorOnNondeterministicMerge, @@ -657,7 +671,7 @@ var AllAccountParameters = []AccountParameter{ AccountParameterJdbcTreatDecimalAsInt, AccountParameterJdbcTreatTimestampNtzAsUtc, AccountParameterJdbcUseSessionTimezone, - AccountParameterJSONIndent, + AccountParameterJsonIndent, AccountParameterJsTreatIntegerAsBigInt, AccountParameterLockTimeout, AccountParameterMultiStatementCount, @@ -672,7 +686,7 @@ var AllAccountParameters = []AccountParameter{ AccountParameterSearchPath, AccountParameterSimulatedDataSharingConsumer, AccountParameterStatementTimeoutInSeconds, - AccountParameterStrictJSONOutput, + AccountParameterStrictJsonOutput, AccountParameterTimeInputFormat, AccountParameterTimeOutputFormat, AccountParameterTimestampDayIsAlways24h, @@ -742,6 +756,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" @@ -753,7 +768,7 @@ const ( 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" @@ -770,7 +785,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" @@ -1196,18 +1211,18 @@ type AccountParameters struct { 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)) + if l < 0.0 { + errs = append(errs, fmt.Errorf("InitialReplicationSizeLimitInTB must be 0.0 and above with a scale of at least 1 (e.g. 20.5, 32.25, 33.333, etc.), got %f", l)) } } if valueSet(v.MinDataRetentionTimeInDays) { - if !validateIntInRange(*v.MinDataRetentionTimeInDays, 0, 90) { + if !validateIntInRangeInclusive(*v.MinDataRetentionTimeInDays, 0, 90) { errs = append(errs, errIntBetween("AccountParameters", "MinDataRetentionTimeInDays", 0, 90)) } } @@ -1442,6 +1457,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"` @@ -1453,7 +1469,7 @@ type SessionParameters struct { 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"` @@ -1470,7 +1486,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"` @@ -1493,9 +1509,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, 16)) } } if valueSet(v.LockTimeout) { @@ -1503,9 +1541,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) { @@ -1513,19 +1551,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, 7) { - errs = append(errs, fmt.Errorf("WEEK_START must be between 0 and 7 (inclusive)")) + if !validateIntGreaterThanOrEqual(*v.WeekStart, 0) { + errs = append(errs, errIntValue("SessionParameters", "WeekStart", IntErrGreaterOrEqual, 0)) } } return errors.Join(errs...) @@ -1547,6 +1595,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"` @@ -1558,7 +1607,7 @@ type SessionParametersUnset struct { 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"` @@ -1575,7 +1624,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"` @@ -1597,37 +1646,40 @@ type SessionParametersUnset struct { } func (v *SessionParametersUnset) validate() error { - 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.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", "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")) + 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)) } } @@ -1637,7 +1689,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)) } } @@ -1656,9 +1708,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...) @@ -1679,6 +1741,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 af2b09c65e..80600f292e 100644 --- a/pkg/sdk/parameters_impl.go +++ b/pkg/sdk/parameters_impl.go @@ -55,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: @@ -77,8 +79,8 @@ func (sessionParameters *SessionParameters) setParam(parameter SessionParameter, 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: @@ -111,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: @@ -217,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: @@ -239,8 +243,8 @@ func (sessionParametersUnset *SessionParametersUnset) setParam(parameter Session 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: @@ -273,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 87fe15199d..3b86f5d2da 100644 --- a/pkg/sdk/parameters_impl_test.go +++ b/pkg/sdk/parameters_impl_test.go @@ -28,6 +28,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 }}, @@ -38,7 +39,7 @@ func TestSessionParameters_setParam(t *testing.T) { {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: 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 }}, @@ -54,7 +55,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 }}, @@ -102,7 +103,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 @@ -110,7 +111,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 15ac3deb71..93592e1f1e 100644 --- a/pkg/sdk/parameters_test.go +++ b/pkg/sdk/parameters_test.go @@ -104,6 +104,7 @@ func TestToAccountParameter(t *testing.T) { {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}, @@ -115,7 +116,7 @@ func TestToAccountParameter(t *testing.T) { {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: "JSON_INDENT", want: AccountParameterJsonIndent}, {input: "JS_TREAT_INTEGER_AS_BIGINT", want: AccountParameterJsTreatIntegerAsBigInt}, {input: "LOCK_TIMEOUT", want: AccountParameterLockTimeout}, {input: "MULTI_STATEMENT_COUNT", want: AccountParameterMultiStatementCount}, @@ -129,7 +130,7 @@ func TestToAccountParameter(t *testing.T) { {input: "S3_STAGE_VPCE_DNS_NAME", want: AccountParameterS3StageVpceDnsName}, {input: "SEARCH_PATH", want: AccountParameterSearchPath}, {input: "SIMULATED_DATA_SHARING_CONSUMER", want: AccountParameterSimulatedDataSharingConsumer}, - {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}, 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..38cff4f5f6 100644 --- a/pkg/sdk/tasks_gen_test.go +++ b/pkg/sdk/tasks_gen_test.go @@ -45,7 +45,7 @@ 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(25), } assertOptsInvalidJoinedErrors(t, opts, errIntBetween("SessionParameters", "JSONIndent", 0, 16)) }) @@ -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..d6f4af90e2 100644 --- a/pkg/sdk/validations_test.go +++ b/pkg/sdk/validations_test.go @@ -170,12 +170,12 @@ func TestValueSet(t *testing.T) { func TestValidateIntInRange(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") } }