diff --git a/clients/bigquery/converters/converters_test.go b/clients/bigquery/converters/converters_test.go index ad1379322..9aa3491f6 100644 --- a/clients/bigquery/converters/converters_test.go +++ b/clients/bigquery/converters/converters_test.go @@ -38,7 +38,7 @@ func TestStringConverter_Convert(t *testing.T) { } { // Extended time - val, err := converter.Convert(ext.NewExtendedTime(time.Date(2021, 1, 1, 0, 0, 0, 0, time.UTC), ext.DateTimeKindType, "")) + val, err := converter.Convert(ext.NewExtendedTime(time.Date(2021, 1, 1, 0, 0, 0, 0, time.UTC), ext.TimestampTzKindType, "")) assert.NoError(t, err) assert.Equal(t, "2021-01-01T00:00:00Z", val) } diff --git a/clients/bigquery/dialect/dialect.go b/clients/bigquery/dialect/dialect.go index 826a65c26..0005a63b3 100644 --- a/clients/bigquery/dialect/dialect.go +++ b/clients/bigquery/dialect/dialect.go @@ -49,7 +49,7 @@ func (BigQueryDialect) DataTypeForKind(kindDetails typing.KindDetails, _ bool) s return "json" case typing.ETime.Kind: switch kindDetails.ExtendedTimeDetails.Type { - case ext.DateTimeKindType: + case ext.TimestampTzKindType: // https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#datetime_type // We should be using TIMESTAMP since it's an absolute point in time. return "timestamp" @@ -104,7 +104,7 @@ func (BigQueryDialect) KindForDataType(rawBqType string, _ string) (typing.KindD case "array": return typing.Array, nil case "datetime", "timestamp": - return typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), nil + return typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), nil case "time": return typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimeKindType), nil case "date": diff --git a/clients/bigquery/dialect/dialect_test.go b/clients/bigquery/dialect/dialect_test.go index afecfb961..626f6e926 100644 --- a/clients/bigquery/dialect/dialect_test.go +++ b/clients/bigquery/dialect/dialect_test.go @@ -86,8 +86,8 @@ func TestBigQueryDialect_KindForDataType(t *testing.T) { "record": typing.Struct, "json": typing.Struct, // Datetime - "datetime": typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), - "timestamp": typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), + "datetime": typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), + "timestamp": typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), "time": typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimeKindType), "date": typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateKindType), //Invalid @@ -125,7 +125,7 @@ func TestBigQueryDialect_KindForDataType(t *testing.T) { func TestBigQueryDialect_KindForDataType_NoDataLoss(t *testing.T) { kindDetails := []typing.KindDetails{ - typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), + typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimeKindType), typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateKindType), typing.String, diff --git a/clients/bigquery/storagewrite.go b/clients/bigquery/storagewrite.go index 055619b01..112bb7d90 100644 --- a/clients/bigquery/storagewrite.go +++ b/clients/bigquery/storagewrite.go @@ -44,7 +44,7 @@ func columnToTableFieldSchema(column columns.Column) (*storagepb.TableFieldSchem fieldType = storagepb.TableFieldSchema_TIME case ext.DateKindType: fieldType = storagepb.TableFieldSchema_DATE - case ext.DateTimeKindType: + case ext.TimestampTzKindType: fieldType = storagepb.TableFieldSchema_TIMESTAMP default: return nil, fmt.Errorf("unsupported extended time details type: %q", column.KindDetails.ExtendedTimeDetails.Type) @@ -185,7 +185,7 @@ func rowToMessage(row map[string]any, columns []columns.Column, messageDescripto case ext.DateKindType: daysSinceEpoch := extTime.GetTime().Unix() / (60 * 60 * 24) message.Set(field, protoreflect.ValueOfInt32(int32(daysSinceEpoch))) - case ext.DateTimeKindType: + case ext.TimestampTzKindType: if err := timestamppb.New(extTime.GetTime()).CheckValid(); err != nil { return nil, err } diff --git a/clients/bigquery/storagewrite_test.go b/clients/bigquery/storagewrite_test.go index 865497991..a9d1fafc1 100644 --- a/clients/bigquery/storagewrite_test.go +++ b/clients/bigquery/storagewrite_test.go @@ -55,8 +55,8 @@ func TestColumnToTableFieldSchema(t *testing.T) { assert.Equal(t, storagepb.TableFieldSchema_DATE, fieldSchema.Type) } { - // ETime - DateTime: - fieldSchema, err := columnToTableFieldSchema(columns.NewColumn("foo", typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType))) + // ETime - TimestampTz: + fieldSchema, err := columnToTableFieldSchema(columns.NewColumn("foo", typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType))) assert.NoError(t, err) assert.Equal(t, storagepb.TableFieldSchema_TIMESTAMP, fieldSchema.Type) } @@ -114,7 +114,7 @@ func TestRowToMessage(t *testing.T) { columns.NewColumn("c_string_decimal", typing.String), columns.NewColumn("c_time", typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimeKindType)), columns.NewColumn("c_date", typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateKindType)), - columns.NewColumn("c_datetime", typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType)), + columns.NewColumn("c_datetime", typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType)), columns.NewColumn("c_struct", typing.Struct), columns.NewColumn("c_array", typing.Array), } @@ -134,7 +134,7 @@ func TestRowToMessage(t *testing.T) { "c_string_decimal": decimal.NewDecimal(numbers.MustParseDecimal("1.61803")), "c_time": ext.NewExtendedTime(time.Date(0, 0, 0, 4, 5, 6, 7, time.UTC), ext.TimeKindType, ""), "c_date": ext.NewExtendedTime(time.Date(2001, 2, 3, 0, 0, 0, 0, time.UTC), ext.DateKindType, ""), - "c_datetime": ext.NewExtendedTime(time.Date(2001, 2, 3, 4, 5, 6, 7, time.UTC), ext.DateTimeKindType, ""), + "c_datetime": ext.NewExtendedTime(time.Date(2001, 2, 3, 4, 5, 6, 7, time.UTC), ext.TimestampTzKindType, ""), "c_struct": map[string]any{"baz": []string{"foo", "bar"}}, "c_array": []string{"foo", "bar"}, } diff --git a/clients/mssql/dialect/dialect.go b/clients/mssql/dialect/dialect.go index 25a916250..ee1d57363 100644 --- a/clients/mssql/dialect/dialect.go +++ b/clients/mssql/dialect/dialect.go @@ -55,7 +55,7 @@ func (MSSQLDialect) DataTypeForKind(kindDetails typing.KindDetails, isPk bool) s return "BIT" case typing.ETime.Kind: switch kindDetails.ExtendedTimeDetails.Type { - case ext.DateTimeKindType: + case ext.TimestampTzKindType: // Using datetime2 because it's the recommendation, and it provides more precision: https://stackoverflow.com/a/1884088 return "datetime2" case ext.DateKindType: @@ -114,7 +114,7 @@ func (MSSQLDialect) KindForDataType(rawType string, stringPrecision string) (typ case "datetime", "datetime2": - return typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), nil + return typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), nil case "time": return typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimeKindType), nil case "date": diff --git a/clients/mssql/dialect/dialect_test.go b/clients/mssql/dialect/dialect_test.go index cfd813c6c..5386048cd 100644 --- a/clients/mssql/dialect/dialect_test.go +++ b/clients/mssql/dialect/dialect_test.go @@ -64,8 +64,8 @@ func TestMSSQLDialect_KindForDataType(t *testing.T) { "bit": typing.Boolean, "date": typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateKindType), "time": typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimeKindType), - "datetime": typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), - "datetime2": typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), + "datetime": typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), + "datetime2": typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), } for col, expectedKind := range colToExpectedKind { diff --git a/clients/redshift/dialect/dialect.go b/clients/redshift/dialect/dialect.go index bd6fc2a1e..daa7fc955 100644 --- a/clients/redshift/dialect/dialect.go +++ b/clients/redshift/dialect/dialect.go @@ -48,7 +48,7 @@ func (RedshiftDialect) DataTypeForKind(kd typing.KindDetails, _ bool) string { return "BOOLEAN NULL" case typing.ETime.Kind: switch kd.ExtendedTimeDetails.Type { - case ext.DateTimeKindType: + case ext.TimestampTzKindType: return "timestamp with time zone" case ext.DateKindType: return "date" @@ -92,7 +92,7 @@ func (RedshiftDialect) KindForDataType(rawType string, stringPrecision string) ( case "double precision": return typing.Float, nil case "timestamp with time zone", "timestamp without time zone": - return typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), nil + return typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), nil case "time without time zone": return typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimeKindType), nil case "date": diff --git a/clients/redshift/dialect/dialect_test.go b/clients/redshift/dialect/dialect_test.go index fe2f22023..856ef4fb4 100644 --- a/clients/redshift/dialect/dialect_test.go +++ b/clients/redshift/dialect/dialect_test.go @@ -99,13 +99,13 @@ func TestRedshiftDialect_KindForDataType(t *testing.T) { kd, err := dialect.KindForDataType("timestamp with time zone", "") assert.NoError(t, err) assert.Equal(t, typing.ETime.Kind, kd.Kind) - assert.Equal(t, ext.DateTimeKindType, kd.ExtendedTimeDetails.Type) + assert.Equal(t, ext.TimestampTzKindType, kd.ExtendedTimeDetails.Type) } { kd, err := dialect.KindForDataType("timestamp without time zone", "") assert.NoError(t, err) assert.Equal(t, typing.ETime.Kind, kd.Kind) - assert.Equal(t, ext.DateTimeKindType, kd.ExtendedTimeDetails.Type) + assert.Equal(t, ext.TimestampTzKindType, kd.ExtendedTimeDetails.Type) } { kd, err := dialect.KindForDataType("time without time zone", "") diff --git a/clients/shared/default_value_test.go b/clients/shared/default_value_test.go index 6771d63d6..56b1123d7 100644 --- a/clients/shared/default_value_test.go +++ b/clients/shared/default_value_test.go @@ -25,7 +25,7 @@ var dialects = []sql.Dialect{ func TestColumn_DefaultValue(t *testing.T) { birthday := time.Date(2022, time.September, 6, 3, 19, 24, 942000000, time.UTC) - birthdayExtDateTime, err := ext.ParseExtendedDateTime(birthday.Format(ext.ISO8601), ext.DateTimeKindType) + birthdayExtDateTime, err := ext.ParseExtendedDateTime(birthday.Format(ext.ISO8601), ext.TimestampTzKindType) assert.NoError(t, err) // date @@ -36,7 +36,7 @@ func TestColumn_DefaultValue(t *testing.T) { timeKind.ExtendedTimeDetails = &ext.Time // date time dateTimeKind := typing.ETime - dateTimeKind.ExtendedTimeDetails = &ext.DateTime + dateTimeKind.ExtendedTimeDetails = &ext.TimestampTz testCases := []struct { name string diff --git a/clients/snowflake/ddl_test.go b/clients/snowflake/ddl_test.go index 81fd08525..ea73f30a4 100644 --- a/clients/snowflake/ddl_test.go +++ b/clients/snowflake/ddl_test.go @@ -29,7 +29,7 @@ func (s *SnowflakeTestSuite) TestMutateColumnsWithMemoryCacheDeletions() { "customer_id": typing.Integer, "price": typing.Float, "name": typing.String, - "created_at": typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), + "created_at": typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), } { cols.AddColumn(columns.NewColumn(colName, kindDetails)) } @@ -58,7 +58,7 @@ func (s *SnowflakeTestSuite) TestShouldDeleteColumn() { "customer_id": typing.Integer, "price": typing.Float, "name": typing.String, - "created_at": typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), + "created_at": typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), } { cols.AddColumn(columns.NewColumn(colName, kindDetails)) } @@ -97,7 +97,7 @@ func (s *SnowflakeTestSuite) TestManipulateShouldDeleteColumn() { "customer_id": typing.Integer, "price": typing.Float, "name": typing.String, - "created_at": typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), + "created_at": typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), } { cols.AddColumn(columns.NewColumn(colName, kindDetails)) } diff --git a/clients/snowflake/dialect/dialect.go b/clients/snowflake/dialect/dialect.go index 7257460a9..d2358d2f6 100644 --- a/clients/snowflake/dialect/dialect.go +++ b/clients/snowflake/dialect/dialect.go @@ -32,7 +32,7 @@ func (SnowflakeDialect) DataTypeForKind(kindDetails typing.KindDetails, _ bool) return "boolean" case typing.ETime.Kind: switch kindDetails.ExtendedTimeDetails.Type { - case ext.DateTimeKindType: + case ext.TimestampTzKindType: // We are not using `TIMESTAMP_NTZ` because Snowflake does not join on this data very well. // It ends up trying to parse this data into a TIMESTAMP_TZ and messes with the join order. // Specifically, if my location is in SF, it'll try to parse TIMESTAMP_NTZ into PST then into UTC. @@ -100,7 +100,7 @@ func (SnowflakeDialect) KindForDataType(snowflakeType string, _ string) (typing. case "array": return typing.Array, nil case "datetime", "timestamp", "timestamp_ltz", "timestamp_ntz", "timestamp_tz": - return typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), nil + return typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), nil case "time": return typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimeKindType), nil case "date": diff --git a/clients/snowflake/dialect/dialect_test.go b/clients/snowflake/dialect/dialect_test.go index 18b7cba46..a15fdd071 100644 --- a/clients/snowflake/dialect/dialect_test.go +++ b/clients/snowflake/dialect/dialect_test.go @@ -178,13 +178,13 @@ func TestSnowflakeDialect_KindForDataType_DateTime(t *testing.T) { for _, expectedDateTime := range expectedDateTimes { kd, err := SnowflakeDialect{}.KindForDataType(expectedDateTime, "") assert.NoError(t, err) - assert.Equal(t, ext.DateTime.Type, kd.ExtendedTimeDetails.Type, expectedDateTime) + assert.Equal(t, ext.TimestampTz.Type, kd.ExtendedTimeDetails.Type, expectedDateTime) } } func TestSnowflakeDialect_KindForDataType_NoDataLoss(t *testing.T) { kindDetails := []typing.KindDetails{ - typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), + typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimeKindType), typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateKindType), typing.String, diff --git a/clients/snowflake/snowflake_test.go b/clients/snowflake/snowflake_test.go index 8d8851af5..520bcd818 100644 --- a/clients/snowflake/snowflake_test.go +++ b/clients/snowflake/snowflake_test.go @@ -243,7 +243,7 @@ func (s *SnowflakeTestSuite) TestExecuteMergeDeletionFlagRemoval() { snowflakeColToKindDetailsMap := map[string]typing.KindDetails{ "id": typing.Integer, - "created_at": typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), + "created_at": typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), "name": typing.String, constants.DeleteColumnMarker: typing.Boolean, constants.OnlySetDeleteColumnMarker: typing.Boolean, diff --git a/lib/cdc/mongo/debezium.go b/lib/cdc/mongo/debezium.go index 3135c2514..72850d766 100644 --- a/lib/cdc/mongo/debezium.go +++ b/lib/cdc/mongo/debezium.go @@ -184,11 +184,11 @@ func (s *SchemaEventPayload) GetData(pkMap map[string]any, tc kafkalib.TopicConf } if tc.IncludeArtieUpdatedAt { - retMap[constants.UpdateColumnMarker] = ext.NewExtendedTime(time.Now().UTC(), ext.DateTimeKindType, ext.ISO8601) + retMap[constants.UpdateColumnMarker] = ext.NewExtendedTime(time.Now().UTC(), ext.TimestampTzKindType, ext.ISO8601) } if tc.IncludeDatabaseUpdatedAt { - retMap[constants.DatabaseUpdatedColumnMarker] = ext.NewExtendedTime(s.GetExecutionTime(), ext.DateTimeKindType, ext.ISO8601) + retMap[constants.DatabaseUpdatedColumnMarker] = ext.NewExtendedTime(s.GetExecutionTime(), ext.TimestampTzKindType, ext.ISO8601) } return retMap, nil diff --git a/lib/cdc/mongo/debezium_test.go b/lib/cdc/mongo/debezium_test.go index 980e86f08..3d829383f 100644 --- a/lib/cdc/mongo/debezium_test.go +++ b/lib/cdc/mongo/debezium_test.go @@ -171,7 +171,7 @@ func (m *MongoTestSuite) TestMongoDBEventCustomer() { evtDataWithIncludedAt, err = evt.GetData(map[string]any{"_id": 1003}, kafkalib.TopicConfig{IncludeDatabaseUpdatedAt: true, IncludeArtieUpdatedAt: true}) assert.NoError(m.T(), err) - assert.Equal(m.T(), ext.NewExtendedTime(time.Date(2022, time.November, 18, 6, 35, 21, 0, time.UTC), ext.DateTimeKindType, ext.ISO8601), evtDataWithIncludedAt[constants.DatabaseUpdatedColumnMarker]) + assert.Equal(m.T(), ext.NewExtendedTime(time.Date(2022, time.November, 18, 6, 35, 21, 0, time.UTC), ext.TimestampTzKindType, ext.ISO8601), evtDataWithIncludedAt[constants.DatabaseUpdatedColumnMarker]) updatedExtTime, isOk := evtDataWithIncludedAt[constants.UpdateColumnMarker].(*ext.ExtendedTime) assert.True(m.T(), isOk) diff --git a/lib/cdc/relational/debezium_test.go b/lib/cdc/relational/debezium_test.go index 90236c185..ab09a3d16 100644 --- a/lib/cdc/relational/debezium_test.go +++ b/lib/cdc/relational/debezium_test.go @@ -90,7 +90,7 @@ func (r *RelationTestSuite) TestPostgresEvent() { evtData, err := evt.GetData(map[string]any{"id": 59}, kafkalib.TopicConfig{IncludeDatabaseUpdatedAt: true}) assert.NoError(r.T(), err) assert.Equal(r.T(), float64(59), evtData["id"]) - assert.Equal(r.T(), ext.NewExtendedTime(time.Date(2022, time.November, 16, 4, 1, 53, 308000000, time.UTC), ext.DateTimeKindType, ext.ISO8601), evtData[constants.DatabaseUpdatedColumnMarker]) + assert.Equal(r.T(), ext.NewExtendedTime(time.Date(2022, time.November, 16, 4, 1, 53, 308000000, time.UTC), ext.TimestampTzKindType, ext.ISO8601), evtData[constants.DatabaseUpdatedColumnMarker]) assert.Equal(r.T(), "Barings Participation Investors", evtData["item"]) assert.Equal(r.T(), map[string]any{"object": "foo"}, evtData["nested"]) @@ -208,7 +208,7 @@ func (r *RelationTestSuite) TestPostgresEventWithSchemaAndTimestampNoTZ() { r.T(), ext.NewExtendedTime( time.Date(2023, time.February, 2, 17, 51, 35, 175445*1000, time.UTC), - ext.DateTimeKindType, ext.RFC3339Microsecond, + ext.TimestampTzKindType, ext.RFC3339Microsecond, ), evtData["ts_no_tz1"], ) @@ -534,7 +534,7 @@ func (r *RelationTestSuite) TestGetEventFromBytes_MySQL() { evtData, err = evt.GetData(kvMap, kafkalib.TopicConfig{IncludeDatabaseUpdatedAt: true, IncludeArtieUpdatedAt: true}) assert.NoError(r.T(), err) - assert.Equal(r.T(), ext.NewExtendedTime(time.Date(2023, time.March, 13, 19, 19, 24, 0, time.UTC), ext.DateTimeKindType, ext.ISO8601), evtData[constants.DatabaseUpdatedColumnMarker]) + assert.Equal(r.T(), ext.NewExtendedTime(time.Date(2023, time.March, 13, 19, 19, 24, 0, time.UTC), ext.TimestampTzKindType, ext.ISO8601), evtData[constants.DatabaseUpdatedColumnMarker]) updatedAtExtTime, isOk := evtData[constants.UpdateColumnMarker].(*ext.ExtendedTime) assert.True(r.T(), isOk) diff --git a/lib/cdc/util/relational_event.go b/lib/cdc/util/relational_event.go index a310301ab..2c500f412 100644 --- a/lib/cdc/util/relational_event.go +++ b/lib/cdc/util/relational_event.go @@ -111,11 +111,11 @@ func (s *SchemaEventPayload) GetData(pkMap map[string]any, tc kafkalib.TopicConf } if tc.IncludeArtieUpdatedAt { - retMap[constants.UpdateColumnMarker] = ext.NewExtendedTime(time.Now().UTC(), ext.DateTimeKindType, ext.ISO8601) + retMap[constants.UpdateColumnMarker] = ext.NewExtendedTime(time.Now().UTC(), ext.TimestampTzKindType, ext.ISO8601) } if tc.IncludeDatabaseUpdatedAt { - retMap[constants.DatabaseUpdatedColumnMarker] = ext.NewExtendedTime(s.GetExecutionTime(), ext.DateTimeKindType, ext.ISO8601) + retMap[constants.DatabaseUpdatedColumnMarker] = ext.NewExtendedTime(s.GetExecutionTime(), ext.TimestampTzKindType, ext.ISO8601) } return retMap, nil diff --git a/lib/debezium/converters/time.go b/lib/debezium/converters/time.go index a0a415e42..7adec53a9 100644 --- a/lib/debezium/converters/time.go +++ b/lib/debezium/converters/time.go @@ -71,7 +71,7 @@ var SupportedDateTimeWithTimezoneFormats = []string{ type DateTimeWithTimezone struct{} func (DateTimeWithTimezone) ToKindDetails() typing.KindDetails { - return typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType) + return typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType) } func (DateTimeWithTimezone) Convert(value any) (any, error) { @@ -97,7 +97,7 @@ func (DateTimeWithTimezone) Convert(value any) (any, error) { for _, supportedFormat := range SupportedDateTimeWithTimezoneFormats { ts, err = ext.ParseTimeExactMatch(supportedFormat, valString) if err == nil { - return ext.NewExtendedTime(ts, ext.DateTimeKindType, supportedFormat), nil + return ext.NewExtendedTime(ts, ext.TimestampTzKindType, supportedFormat), nil } } diff --git a/lib/debezium/converters/time_test.go b/lib/debezium/converters/time_test.go index c5d898e63..535c84735 100644 --- a/lib/debezium/converters/time_test.go +++ b/lib/debezium/converters/time_test.go @@ -39,7 +39,7 @@ func TestConvertDateTimeWithTimezone(t *testing.T) { ts, isOk := val.(*ext.ExtendedTime) assert.True(t, isOk) - expectedExtTime := ext.NewExtendedTime(time.Date(2025, time.September, 13, 0, 0, 0, 000000000, time.UTC), ext.DateTimeKindType, "2006-01-02T15:04:05Z") + expectedExtTime := ext.NewExtendedTime(time.Date(2025, time.September, 13, 0, 0, 0, 000000000, time.UTC), ext.TimestampTzKindType, "2006-01-02T15:04:05Z") assert.Equal(t, expectedExtTime, ts) } { @@ -50,7 +50,7 @@ func TestConvertDateTimeWithTimezone(t *testing.T) { ts, isOk := val.(*ext.ExtendedTime) assert.True(t, isOk) - expectedExtTime := ext.NewExtendedTime(time.Date(2025, time.September, 13, 0, 0, 0, 100000000, time.UTC), ext.DateTimeKindType, "2006-01-02T15:04:05.0Z") + expectedExtTime := ext.NewExtendedTime(time.Date(2025, time.September, 13, 0, 0, 0, 100000000, time.UTC), ext.TimestampTzKindType, "2006-01-02T15:04:05.0Z") assert.Equal(t, expectedExtTime, ts) } { @@ -61,7 +61,7 @@ func TestConvertDateTimeWithTimezone(t *testing.T) { ts, isOk := val.(*ext.ExtendedTime) assert.True(t, isOk) - expectedExtTime := ext.NewExtendedTime(time.Date(2025, time.September, 13, 0, 0, 0, 120000000, time.UTC), ext.DateTimeKindType, "2006-01-02T15:04:05.00Z") + expectedExtTime := ext.NewExtendedTime(time.Date(2025, time.September, 13, 0, 0, 0, 120000000, time.UTC), ext.TimestampTzKindType, "2006-01-02T15:04:05.00Z") assert.Equal(t, expectedExtTime, ts) } { @@ -72,7 +72,7 @@ func TestConvertDateTimeWithTimezone(t *testing.T) { ts, isOk := val.(*ext.ExtendedTime) assert.True(t, isOk) - expectedExtTime := ext.NewExtendedTime(time.Date(2025, time.September, 13, 0, 0, 0, 123000000, time.UTC), ext.DateTimeKindType, "2006-01-02T15:04:05.000Z") + expectedExtTime := ext.NewExtendedTime(time.Date(2025, time.September, 13, 0, 0, 0, 123000000, time.UTC), ext.TimestampTzKindType, "2006-01-02T15:04:05.000Z") assert.Equal(t, expectedExtTime, ts) } { @@ -83,7 +83,7 @@ func TestConvertDateTimeWithTimezone(t *testing.T) { ts, isOk := val.(*ext.ExtendedTime) assert.True(t, isOk) - expectedExtTime := ext.NewExtendedTime(time.Date(2025, time.September, 13, 0, 0, 0, 123400000, time.UTC), ext.DateTimeKindType, "2006-01-02T15:04:05.0000Z") + expectedExtTime := ext.NewExtendedTime(time.Date(2025, time.September, 13, 0, 0, 0, 123400000, time.UTC), ext.TimestampTzKindType, "2006-01-02T15:04:05.0000Z") assert.Equal(t, expectedExtTime, ts) } { @@ -94,7 +94,7 @@ func TestConvertDateTimeWithTimezone(t *testing.T) { ts, isOk := val.(*ext.ExtendedTime) assert.True(t, isOk) - expectedExtTime := ext.NewExtendedTime(time.Date(2025, time.September, 13, 0, 0, 0, 123450000, time.UTC), ext.DateTimeKindType, "2006-01-02T15:04:05.00000Z") + expectedExtTime := ext.NewExtendedTime(time.Date(2025, time.September, 13, 0, 0, 0, 123450000, time.UTC), ext.TimestampTzKindType, "2006-01-02T15:04:05.00000Z") assert.Equal(t, expectedExtTime, ts) } { @@ -105,7 +105,7 @@ func TestConvertDateTimeWithTimezone(t *testing.T) { ts, isOk := val.(*ext.ExtendedTime) assert.True(t, isOk) - expectedExtTime := ext.NewExtendedTime(time.Date(2025, time.September, 13, 0, 0, 0, 123456000, time.UTC), ext.DateTimeKindType, "2006-01-02T15:04:05.000000Z") + expectedExtTime := ext.NewExtendedTime(time.Date(2025, time.September, 13, 0, 0, 0, 123456000, time.UTC), ext.TimestampTzKindType, "2006-01-02T15:04:05.000000Z") assert.Equal(t, expectedExtTime, ts) } } diff --git a/lib/debezium/converters/timestamp.go b/lib/debezium/converters/timestamp.go index 94c4e73d6..a5660ae2e 100644 --- a/lib/debezium/converters/timestamp.go +++ b/lib/debezium/converters/timestamp.go @@ -10,7 +10,7 @@ import ( type Timestamp struct{} func (Timestamp) ToKindDetails() typing.KindDetails { - return typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType) + return typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType) } func (Timestamp) Convert(value any) (any, error) { @@ -20,13 +20,13 @@ func (Timestamp) Convert(value any) (any, error) { } // Represents the number of milliseconds since the epoch, and does not include timezone information. - return ext.NewExtendedTime(time.UnixMilli(castedValue).In(time.UTC), ext.DateTimeKindType, ext.RFC3339Millisecond), nil + return ext.NewExtendedTime(time.UnixMilli(castedValue).In(time.UTC), ext.TimestampTzKindType, ext.RFC3339Millisecond), nil } type MicroTimestamp struct{} func (MicroTimestamp) ToKindDetails() typing.KindDetails { - return typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType) + return typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType) } func (MicroTimestamp) Convert(value any) (any, error) { @@ -36,13 +36,13 @@ func (MicroTimestamp) Convert(value any) (any, error) { } // Represents the number of microseconds since the epoch, and does not include timezone information. - return ext.NewExtendedTime(time.UnixMicro(castedValue).In(time.UTC), ext.DateTimeKindType, ext.RFC3339Microsecond), nil + return ext.NewExtendedTime(time.UnixMicro(castedValue).In(time.UTC), ext.TimestampTzKindType, ext.RFC3339Microsecond), nil } type NanoTimestamp struct{} func (NanoTimestamp) ToKindDetails() typing.KindDetails { - return typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType) + return typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType) } func (NanoTimestamp) Convert(value any) (any, error) { @@ -52,5 +52,5 @@ func (NanoTimestamp) Convert(value any) (any, error) { } // Represents the number of nanoseconds since the epoch, and does not include timezone information. - return ext.NewExtendedTime(time.UnixMicro(castedValue/1_000).In(time.UTC), ext.DateTimeKindType, ext.RFC3339Nanosecond), nil + return ext.NewExtendedTime(time.UnixMicro(castedValue/1_000).In(time.UTC), ext.TimestampTzKindType, ext.RFC3339Nanosecond), nil } diff --git a/lib/debezium/converters/timestamp_test.go b/lib/debezium/converters/timestamp_test.go index f11f1f72f..b54f63e87 100644 --- a/lib/debezium/converters/timestamp_test.go +++ b/lib/debezium/converters/timestamp_test.go @@ -9,7 +9,7 @@ import ( ) func TestTimestamp_Converter(t *testing.T) { - assert.Equal(t, typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), Timestamp{}.ToKindDetails()) + assert.Equal(t, typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), Timestamp{}.ToKindDetails()) { // Invalid conversion _, err := Timestamp{}.Convert("invalid") @@ -30,7 +30,7 @@ func TestTimestamp_Converter(t *testing.T) { } func TestMicroTimestamp_Converter(t *testing.T) { - assert.Equal(t, typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), MicroTimestamp{}.ToKindDetails()) + assert.Equal(t, typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), MicroTimestamp{}.ToKindDetails()) { // Invalid conversion _, err := MicroTimestamp{}.Convert("invalid") @@ -51,7 +51,7 @@ func TestMicroTimestamp_Converter(t *testing.T) { } func TestNanoTimestamp_Converter(t *testing.T) { - assert.Equal(t, typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), NanoTimestamp{}.ToKindDetails()) + assert.Equal(t, typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), NanoTimestamp{}.ToKindDetails()) { // Invalid conversion _, err := NanoTimestamp{}.Convert("invalid") diff --git a/lib/debezium/schema_test.go b/lib/debezium/schema_test.go index 93a6677dd..fe3acceba 100644 --- a/lib/debezium/schema_test.go +++ b/lib/debezium/schema_test.go @@ -234,7 +234,7 @@ func TestField_ToKindDetails(t *testing.T) { for _, dbzType := range []SupportedDebeziumType{Timestamp, TimestampKafkaConnect, MicroTimestamp, NanoTimestamp, DateTimeWithTimezone} { kd, err := Field{DebeziumType: dbzType}.ToKindDetails() assert.NoError(t, err) - assert.Equal(t, typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), kd) + assert.Equal(t, typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), kd) } } { diff --git a/lib/debezium/types_test.go b/lib/debezium/types_test.go index e888b596d..b8093b81b 100644 --- a/lib/debezium/types_test.go +++ b/lib/debezium/types_test.go @@ -49,11 +49,11 @@ func TestField_ShouldSetDefaultValue(t *testing.T) { { // *ext.ExtendedTime field := Field{} - assert.True(t, field.ShouldSetDefaultValue(ext.NewExtendedTime(time.Now(), ext.DateTimeKindType, ext.RFC3339Millisecond))) + assert.True(t, field.ShouldSetDefaultValue(ext.NewExtendedTime(time.Now(), ext.TimestampTzKindType, ext.RFC3339Millisecond))) assert.False(t, field.ShouldSetDefaultValue(&ext.ExtendedTime{})) var ts time.Time - assert.False(t, field.ShouldSetDefaultValue(ext.NewExtendedTime(ts, ext.DateTimeKindType, ext.RFC3339Millisecond))) + assert.False(t, field.ShouldSetDefaultValue(ext.NewExtendedTime(ts, ext.TimestampTzKindType, ext.RFC3339Millisecond))) } } @@ -310,7 +310,7 @@ func TestField_ParseValue(t *testing.T) { field := Field{Type: Int64, DebeziumType: NanoTimestamp} val, err := field.ParseValue(int64(1_712_609_795_827_000_000)) assert.NoError(t, err) - assert.Equal(t, ext.NewExtendedTime(time.Date(2024, time.April, 8, 20, 56, 35, 827000000, time.UTC), ext.DateTimeKindType, "2006-01-02T15:04:05.000000000Z07:00"), val.(*ext.ExtendedTime)) + assert.Equal(t, ext.NewExtendedTime(time.Date(2024, time.April, 8, 20, 56, 35, 827000000, time.UTC), ext.TimestampTzKindType, "2006-01-02T15:04:05.000000000Z07:00"), val.(*ext.ExtendedTime)) } { // Micro timestamp @@ -319,13 +319,13 @@ func TestField_ParseValue(t *testing.T) { // Int64 val, err := field.ParseValue(int64(1_712_609_795_827_009)) assert.NoError(t, err) - assert.Equal(t, ext.NewExtendedTime(time.Date(2024, time.April, 8, 20, 56, 35, 827009000, time.UTC), ext.DateTimeKindType, ext.RFC3339Microsecond), val.(*ext.ExtendedTime)) + assert.Equal(t, ext.NewExtendedTime(time.Date(2024, time.April, 8, 20, 56, 35, 827009000, time.UTC), ext.TimestampTzKindType, ext.RFC3339Microsecond), val.(*ext.ExtendedTime)) } { // Float64 val, err := field.ParseValue(float64(1_712_609_795_827_001)) assert.NoError(t, err) - assert.Equal(t, ext.NewExtendedTime(time.Date(2024, time.April, 8, 20, 56, 35, 827001000, time.UTC), ext.DateTimeKindType, ext.RFC3339Microsecond), val.(*ext.ExtendedTime)) + assert.Equal(t, ext.NewExtendedTime(time.Date(2024, time.April, 8, 20, 56, 35, 827001000, time.UTC), ext.TimestampTzKindType, ext.RFC3339Microsecond), val.(*ext.ExtendedTime)) } { // Invalid (string) diff --git a/lib/destination/ddl/ddl_sflk_test.go b/lib/destination/ddl/ddl_sflk_test.go index 5b37a0592..757de9e77 100644 --- a/lib/destination/ddl/ddl_sflk_test.go +++ b/lib/destination/ddl/ddl_sflk_test.go @@ -51,7 +51,7 @@ func (d *DDLTestSuite) TestAlterComplexObjects() { func (d *DDLTestSuite) TestAlterIdempotency() { cols := []columns.Column{ - columns.NewColumn("created_at", typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType)), + columns.NewColumn("created_at", typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType)), columns.NewColumn("id", typing.Integer), columns.NewColumn("order_name", typing.String), columns.NewColumn("start", typing.String), @@ -81,7 +81,7 @@ func (d *DDLTestSuite) TestAlterIdempotency() { func (d *DDLTestSuite) TestAlterTableAdd() { // Test adding a bunch of columns cols := []columns.Column{ - columns.NewColumn("created_at", typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType)), + columns.NewColumn("created_at", typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType)), columns.NewColumn("id", typing.Integer), columns.NewColumn("order_name", typing.String), columns.NewColumn("start", typing.String), @@ -123,7 +123,7 @@ func (d *DDLTestSuite) TestAlterTableAdd() { func (d *DDLTestSuite) TestAlterTableDeleteDryRun() { // Test adding a bunch of columns cols := []columns.Column{ - columns.NewColumn("created_at", typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType)), + columns.NewColumn("created_at", typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType)), columns.NewColumn("id", typing.Integer), columns.NewColumn("name", typing.String), columns.NewColumn("start", typing.String), @@ -180,7 +180,7 @@ func (d *DDLTestSuite) TestAlterTableDeleteDryRun() { func (d *DDLTestSuite) TestAlterTableDelete() { // Test adding a bunch of columns cols := []columns.Column{ - columns.NewColumn("created_at", typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType)), + columns.NewColumn("created_at", typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType)), columns.NewColumn("id", typing.Integer), columns.NewColumn("name", typing.String), columns.NewColumn("col_to_delete", typing.String), diff --git a/lib/optimization/event_update_test.go b/lib/optimization/event_update_test.go index 1298afd4d..4fae39c09 100644 --- a/lib/optimization/event_update_test.go +++ b/lib/optimization/event_update_test.go @@ -119,7 +119,7 @@ func TestTableData_UpdateInMemoryColumnsFromDestination(t *testing.T) { assert.NoError(t, tableData.MergeColumnsFromDestination(columns.NewColumn("ext_time", typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimeKindType)))) assert.NoError(t, tableData.MergeColumnsFromDestination(columns.NewColumn("ext_date", typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateKindType)))) - assert.NoError(t, tableData.MergeColumnsFromDestination(columns.NewColumn("ext_datetime", typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType)))) + assert.NoError(t, tableData.MergeColumnsFromDestination(columns.NewColumn("ext_datetime", typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType)))) dateCol, isOk := tableData.inMemoryColumns.GetColumn("ext_date") assert.True(t, isOk) @@ -134,7 +134,7 @@ func TestTableData_UpdateInMemoryColumnsFromDestination(t *testing.T) { dateTimeCol, isOk := tableData.inMemoryColumns.GetColumn("ext_datetime") assert.True(t, isOk) assert.NotNil(t, dateTimeCol.KindDetails.ExtendedTimeDetails) - assert.Equal(t, ext.DateTimeKindType, dateTimeCol.KindDetails.ExtendedTimeDetails.Type) + assert.Equal(t, ext.TimestampTzKindType, dateTimeCol.KindDetails.ExtendedTimeDetails.Type) // Testing extDecimalDetails // Confirm that before you update, it's invalid. diff --git a/lib/optimization/table_data_test.go b/lib/optimization/table_data_test.go index d8fda8bf6..7807e77d8 100644 --- a/lib/optimization/table_data_test.go +++ b/lib/optimization/table_data_test.go @@ -150,9 +150,9 @@ func TestTableData_UpdateInMemoryColumns(t *testing.T) { for name, colKindDetails := range map[string]typing.KindDetails{ "foo": typing.String, - "change_me": typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), + "change_me": typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), "bar": typing.Boolean, - "do_not_change_format": typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType), + "do_not_change_format": typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType), } { tableData.MergeColumnsFromDestination(columns.NewColumn(name, colKindDetails)) } @@ -166,7 +166,7 @@ func TestTableData_UpdateInMemoryColumns(t *testing.T) { col, isOk := tableData.ReadOnlyInMemoryCols().GetColumn("CHANGE_me") assert.True(t, isOk) - assert.Equal(t, ext.DateTime.Type, col.KindDetails.ExtendedTimeDetails.Type) + assert.Equal(t, ext.TimestampTz.Type, col.KindDetails.ExtendedTimeDetails.Type) // It went from invalid to boolean. col, isOk = tableData.ReadOnlyInMemoryCols().GetColumn("bar") @@ -176,7 +176,7 @@ func TestTableData_UpdateInMemoryColumns(t *testing.T) { col, isOk = tableData.ReadOnlyInMemoryCols().GetColumn("do_not_change_format") assert.True(t, isOk) assert.Equal(t, col.KindDetails.Kind, typing.ETime.Kind) - assert.Equal(t, col.KindDetails.ExtendedTimeDetails.Type, ext.DateTimeKindType, "correctly mapped type") + assert.Equal(t, col.KindDetails.ExtendedTimeDetails.Type, ext.TimestampTzKindType, "correctly mapped type") assert.Equal(t, col.KindDetails.ExtendedTimeDetails.Format, time.RFC3339Nano, "format has been preserved") } diff --git a/lib/parquetutil/parse_values_test.go b/lib/parquetutil/parse_values_test.go index b27659739..1cc5ab3cc 100644 --- a/lib/parquetutil/parse_values_test.go +++ b/lib/parquetutil/parse_values_test.go @@ -22,7 +22,7 @@ func TestParseValue(t *testing.T) { eDate.ExtendedTimeDetails = &ext.Date eDateTime := typing.ETime - eDateTime.ExtendedTimeDetails = &ext.DateTime + eDateTime.ExtendedTimeDetails = &ext.TimestampTz testCases := []struct { name string diff --git a/lib/typing/columns/diff_test.go b/lib/typing/columns/diff_test.go index d64ef3339..1d0c3b8c5 100644 --- a/lib/typing/columns/diff_test.go +++ b/lib/typing/columns/diff_test.go @@ -249,8 +249,8 @@ func TestDiffDeterministic(t *testing.T) { func TestCopyColMap(t *testing.T) { var cols Columns cols.AddColumn(NewColumn("hello", typing.String)) - cols.AddColumn(NewColumn("created_at", typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType))) - cols.AddColumn(NewColumn("updated_at", typing.NewKindDetailsFromTemplate(typing.ETime, ext.DateTimeKindType))) + cols.AddColumn(NewColumn("created_at", typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType))) + cols.AddColumn(NewColumn("updated_at", typing.NewKindDetailsFromTemplate(typing.ETime, ext.TimestampTzKindType))) copiedCols := CloneColumns(&cols) assert.Equal(t, copiedCols, &cols) diff --git a/lib/typing/ext/parse.go b/lib/typing/ext/parse.go index 434dda17d..59d564fae 100644 --- a/lib/typing/ext/parse.go +++ b/lib/typing/ext/parse.go @@ -40,7 +40,7 @@ func ParseFromInterface(val any, kindType ExtendedTimeKindType) (*ExtendedTime, func ParseExtendedDateTime(value string, kindType ExtendedTimeKindType) (*ExtendedTime, error) { switch kindType { - case DateTimeKindType: + case TimestampTzKindType: return parseDateTime(value) case DateKindType: // Try date first @@ -72,7 +72,7 @@ func ParseExtendedDateTime(value string, kindType ExtendedTimeKindType) (*Extend func parseDateTime(value string) (*ExtendedTime, error) { for _, supportedDateTimeLayout := range supportedDateTimeLayouts { if ts, err := ParseTimeExactMatch(supportedDateTimeLayout, value); err == nil { - return NewExtendedTime(ts, DateTimeKindType, supportedDateTimeLayout), nil + return NewExtendedTime(ts, TimestampTzKindType, supportedDateTimeLayout), nil } } diff --git a/lib/typing/ext/parse_test.go b/lib/typing/ext/parse_test.go index dfc54f29c..ab73e6b3a 100644 --- a/lib/typing/ext/parse_test.go +++ b/lib/typing/ext/parse_test.go @@ -12,28 +12,28 @@ func TestParseFromInterface(t *testing.T) { // Extended time var vals []any vals = append(vals, NewExtendedTime(time.Now().UTC(), DateKindType, PostgresDateFormat)) - vals = append(vals, NewExtendedTime(time.Now().UTC(), DateTimeKindType, ISO8601)) + vals = append(vals, NewExtendedTime(time.Now().UTC(), TimestampTzKindType, ISO8601)) vals = append(vals, NewExtendedTime(time.Now().UTC(), TimeKindType, PostgresTimeFormat)) for _, val := range vals { - extTime, err := ParseFromInterface(val, DateTimeKindType) + extTime, err := ParseFromInterface(val, TimestampTzKindType) assert.NoError(t, err) assert.Equal(t, val, extTime) } } { // Nil - _, err := ParseFromInterface(nil, DateTimeKindType) + _, err := ParseFromInterface(nil, TimestampTzKindType) assert.ErrorContains(t, err, "val is nil") } { // True - _, err := ParseFromInterface(true, DateTimeKindType) + _, err := ParseFromInterface(true, TimestampTzKindType) assert.ErrorContains(t, err, "failed to parse colVal, expected type string or *ExtendedTime and got: bool") } { // False - _, err := ParseFromInterface(false, DateTimeKindType) + _, err := ParseFromInterface(false, TimestampTzKindType) assert.ErrorContains(t, err, "failed to parse colVal, expected type string or *ExtendedTime and got: bool") } } @@ -41,9 +41,9 @@ func TestParseFromInterface(t *testing.T) { func TestParseFromInterfaceDateTime(t *testing.T) { now := time.Now().In(time.UTC) for _, supportedDateTimeLayout := range supportedDateTimeLayouts { - et, err := ParseFromInterface(now.Format(supportedDateTimeLayout), DateTimeKindType) + et, err := ParseFromInterface(now.Format(supportedDateTimeLayout), TimestampTzKindType) assert.NoError(t, err) - assert.Equal(t, DateTimeKindType, et.GetNestedKind().Type) + assert.Equal(t, TimestampTzKindType, et.GetNestedKind().Type) assert.Equal(t, et.String(""), now.Format(supportedDateTimeLayout)) } } @@ -73,7 +73,7 @@ func TestParseFromInterfaceDate(t *testing.T) { func TestParseExtendedDateTime_Timestamp(t *testing.T) { tsString := "2023-04-24T17:29:05.69944Z" - extTime, err := ParseExtendedDateTime(tsString, DateTimeKindType) + extTime, err := ParseExtendedDateTime(tsString, TimestampTzKindType) assert.NoError(t, err) assert.Equal(t, "2023-04-24T17:29:05.69944Z", extTime.String("")) } diff --git a/lib/typing/ext/time.go b/lib/typing/ext/time.go index 333e67fb5..3294d99e2 100644 --- a/lib/typing/ext/time.go +++ b/lib/typing/ext/time.go @@ -8,9 +8,9 @@ import ( type ExtendedTimeKindType string const ( - DateTimeKindType ExtendedTimeKindType = "datetime" - DateKindType ExtendedTimeKindType = "date" - TimeKindType ExtendedTimeKindType = "time" + TimestampTzKindType ExtendedTimeKindType = "timestamp_tz" + DateKindType ExtendedTimeKindType = "date" + TimeKindType ExtendedTimeKindType = "time" ) type NestedKind struct { @@ -19,8 +19,8 @@ type NestedKind struct { } var ( - DateTime = NestedKind{ - Type: DateTimeKindType, + TimestampTz = NestedKind{ + Type: TimestampTzKindType, Format: time.RFC3339Nano, } @@ -49,8 +49,8 @@ func (e ExtendedTime) MarshalJSON() ([]byte, error) { func NewExtendedTime(t time.Time, kindType ExtendedTimeKindType, originalFormat string) *ExtendedTime { if originalFormat == "" { switch kindType { - case DateTimeKindType: - originalFormat = DateTime.Format + case TimestampTzKindType: + originalFormat = TimestampTz.Format case DateKindType: originalFormat = Date.Format case TimeKindType: diff --git a/lib/typing/ext/time_test.go b/lib/typing/ext/time_test.go index 42dc413d7..d91ed1d2c 100644 --- a/lib/typing/ext/time_test.go +++ b/lib/typing/ext/time_test.go @@ -9,7 +9,7 @@ import ( ) func TestExtendedTime_MarshalJSON(t *testing.T) { - extTime := NewExtendedTime(time.Date(2025, time.September, 13, 0, 0, 0, 123456000, time.UTC), DateTimeKindType, RFC3339Millisecond) + extTime := NewExtendedTime(time.Date(2025, time.September, 13, 0, 0, 0, 123456000, time.UTC), TimestampTzKindType, RFC3339Millisecond) { // Single value diff --git a/lib/typing/mongo/bson.go b/lib/typing/mongo/bson.go index 12c2ed4a3..36cd84796 100644 --- a/lib/typing/mongo/bson.go +++ b/lib/typing/mongo/bson.go @@ -89,9 +89,9 @@ func bsonBinaryValueToMap(value primitive.Binary) (any, error) { func bsonValueToGoValue(value any) (any, error) { switch v := value.(type) { case primitive.DateTime: - return ext.NewExtendedTime(v.Time().UTC(), ext.DateTimeKindType, ext.ISO8601), nil + return ext.NewExtendedTime(v.Time().UTC(), ext.TimestampTzKindType, ext.ISO8601), nil case primitive.Timestamp: - return ext.NewExtendedTime(time.Unix(int64(v.T), 0).UTC(), ext.DateTimeKindType, ext.ISO8601), nil + return ext.NewExtendedTime(time.Unix(int64(v.T), 0).UTC(), ext.TimestampTzKindType, ext.ISO8601), nil case primitive.ObjectID: return v.Hex(), nil case primitive.Binary: diff --git a/lib/typing/mongo/bson_test.go b/lib/typing/mongo/bson_test.go index 5f9681394..e3104ddb8 100644 --- a/lib/typing/mongo/bson_test.go +++ b/lib/typing/mongo/bson_test.go @@ -118,13 +118,13 @@ func TestJSONEToMap(t *testing.T) { // Date extendedTime, isOk := result["order_date"].(*ext.ExtendedTime) assert.True(t, isOk) - assert.Equal(t, ext.NewExtendedTime(time.Date(2016, time.February, 21, 0, 0, 0, 0, time.UTC), ext.DateTimeKindType, ext.ISO8601), extendedTime) + assert.Equal(t, ext.NewExtendedTime(time.Date(2016, time.February, 21, 0, 0, 0, 0, time.UTC), ext.TimestampTzKindType, ext.ISO8601), extendedTime) } { // Timestamp extendedTime, isOk := result["test_timestamp"] assert.True(t, isOk) - assert.Equal(t, ext.NewExtendedTime(time.Date(2023, time.March, 16, 1, 18, 37, 0, time.UTC), ext.DateTimeKindType, ext.ISO8601), extendedTime) + assert.Equal(t, ext.NewExtendedTime(time.Date(2023, time.March, 16, 1, 18, 37, 0, time.UTC), ext.TimestampTzKindType, ext.ISO8601), extendedTime) } { // Boolean @@ -221,7 +221,7 @@ func TestBsonValueToGoValue(t *testing.T) { extendedTime, isOk := result.(*ext.ExtendedTime) assert.True(t, isOk) - assert.Equal(t, ext.NewExtendedTime(time.Date(2021, time.January, 1, 0, 0, 0, 0, time.UTC), ext.DateTimeKindType, ext.ISO8601), extendedTime) + assert.Equal(t, ext.NewExtendedTime(time.Date(2021, time.January, 1, 0, 0, 0, 0, time.UTC), ext.TimestampTzKindType, ext.ISO8601), extendedTime) } { // primitive.ObjectID diff --git a/lib/typing/values/string_test.go b/lib/typing/values/string_test.go index 3f43d3e1f..ebe63680c 100644 --- a/lib/typing/values/string_test.go +++ b/lib/typing/values/string_test.go @@ -44,9 +44,9 @@ func TestToString(t *testing.T) { { // Using `*ExtendedTime` dustyBirthday := time.Date(2019, time.December, 31, 0, 0, 0, 0, time.UTC) - extendedTime := ext.NewExtendedTime(dustyBirthday, ext.DateTimeKindType, "2006-01-02T15:04:05Z07:00") + extendedTime := ext.NewExtendedTime(dustyBirthday, ext.TimestampTzKindType, "2006-01-02T15:04:05Z07:00") - eTimeCol.KindDetails.ExtendedTimeDetails = &ext.NestedKind{Type: ext.DateTimeKindType} + eTimeCol.KindDetails.ExtendedTimeDetails = &ext.NestedKind{Type: ext.TimestampTzKindType} actualValue, err := ToString(extendedTime, eTimeCol.KindDetails) assert.NoError(t, err) assert.Equal(t, extendedTime.String(""), actualValue)