Skip to content

Commit

Permalink
source-postgres: Flip date/time flag defaults
Browse files Browse the repository at this point in the history
To be merged immediately after setting the flags
`no_date_as_date,no_time_as_time` on all production tasks.
  • Loading branch information
willdonnelly committed Feb 20, 2025
1 parent ab523aa commit e5edd3e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion source-postgres/.snapshots/TestPartitionedTableDiscovery
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Binding 0:
"properties": {
"logdate": {
"type": "string",
"format": "date-time",
"format": "date",
"description": "(source type: non-nullable date)"
},
"value": {
Expand Down
24 changes: 7 additions & 17 deletions source-postgres/datatype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,9 @@ func TestDatatypes(t *testing.T) {
{ColumnType: `bit varying(5)`, ExpectType: `{"type":["string","null"]}`, InputValue: `10111`, ExpectValue: `"10111"`},

// Date/Time/Timestamp Types
{ColumnType: `date`, ExpectType: `{"type":["string","null"],"format":"date-time"}`, InputValue: `'January 8, 1999'`, ExpectValue: `"1999-01-08T00:00:00Z"`},
{ColumnType: `date`, ExpectType: `{"type":["string","null"],"format":"date-time"}`, InputValue: `'January 8, 22021'`, ExpectValue: `"0000-01-01T00:00:00Z"`},
{ColumnType: `date`, ExpectType: `{"type":["string","null"],"format":"date-time"}`, InputValue: nil, ExpectValue: `null`},
// Replacement tests for the previous three once "date_as_date" is the default
// {ColumnType: `date`, ExpectType: `{"type":["string","null"],"format":"date"}`, InputValue: `'January 8, 1999'`, ExpectValue: `"1999-01-08"`},
// {ColumnType: `date`, ExpectType: `{"type":["string","null"],"format":"date"}`, InputValue: `'January 8, 22021'`, ExpectValue: `"0000-01-01"`},
// {ColumnType: `date`, ExpectType: `{"type":["string","null"],"format":"date"}`, InputValue: nil, ExpectValue: `null`},
{ColumnType: `date`, ExpectType: `{"type":["string","null"],"format":"date"}`, InputValue: `'January 8, 1999'`, ExpectValue: `"1999-01-08"`},
{ColumnType: `date`, ExpectType: `{"type":["string","null"],"format":"date"}`, InputValue: `'January 8, 22021'`, ExpectValue: `"0000-01-01"`},
{ColumnType: `date`, ExpectType: `{"type":["string","null"],"format":"date"}`, InputValue: nil, ExpectValue: `null`},
{ColumnType: `timestamp`, ExpectType: `{"type":["string","null"],"format":"date-time"}`, InputValue: `'January 8, 1999'`, ExpectValue: `"1999-01-08T00:00:00Z"`},
{ColumnType: `timestamp without time zone`, ExpectType: `{"type":["string","null"],"format":"date-time"}`, InputValue: `'January 8, 1999'`, ExpectValue: `"1999-01-08T00:00:00Z"`},
{ColumnType: `timestamp`, ExpectType: `{"type":["string","null"],"format":"date-time"}`, InputValue: `'infinity'`, ExpectValue: `"9999-12-31T23:59:59Z"`},
Expand All @@ -70,13 +66,9 @@ func TestDatatypes(t *testing.T) {
{ColumnType: `timestamp`, ExpectType: `{"type":["string","null"],"format":"date-time"}`, InputValue: `'20222-08-31T00:00:00Z'`, ExpectValue: `"0000-01-01T00:00:00Z"`},
{ColumnType: `timestamp`, ExpectType: `{"type":["string","null"],"format":"date-time"}`, InputValue: `'January 8, 99 BC'`, ExpectValue: `"0000-01-01T00:00:00Z"`},
{ColumnType: `timestamp with time zone`, ExpectType: `{"type":["string","null"],"format":"date-time"}`, InputValue: `'January 8, 1999 UTC'`, ExpectValue: `"1999-01-07T16:00:00-08:00"`},
{ColumnType: `time`, ExpectType: `{"type":["integer","null"]}`, InputValue: `'04:05:06 PST'`, ExpectValue: `14706000000`},
{ColumnType: `time without time zone`, ExpectType: `{"type":["integer","null"]}`, InputValue: `'04:05:06 PST'`, ExpectValue: `14706000000`},
{ColumnType: `time`, ExpectType: `{"type":["integer","null"]}`, InputValue: nil, ExpectValue: `null`},
// Replacement tests for the previous two once "time_as_time" is the default
// {ColumnType: `time`, ExpectType: `{"type":["string","null"],"format":"time"}`, InputValue: `'04:05:06 PST'`, ExpectValue: `"04:05:06Z"`},
// {ColumnType: `time without time zone`, ExpectType: `{"type":["string","null"],"format":"time"}`, InputValue: `'04:05:06 PST'`, ExpectValue: `"04:05:06Z"`},
// {ColumnType: `time`, ExpectType: `{"type":["string","null"],"format":"time"}`, InputValue: nil, ExpectValue: `null`},
{ColumnType: `time`, ExpectType: `{"type":["string","null"],"format":"time"}`, InputValue: `'04:05:06 PST'`, ExpectValue: `"04:05:06Z"`},
{ColumnType: `time without time zone`, ExpectType: `{"type":["string","null"],"format":"time"}`, InputValue: `'04:05:06 PST'`, ExpectValue: `"04:05:06Z"`},
{ColumnType: `time`, ExpectType: `{"type":["string","null"],"format":"time"}`, InputValue: nil, ExpectValue: `null`},
{ColumnType: `time with time zone`, ExpectType: `{"type":["string","null"],"format":"time"}`, InputValue: `'04:05:06 PST'`, ExpectValue: `"04:05:06-08:00"`},
{ColumnType: `time with time zone`, ExpectType: `{"type":["string","null"],"format":"time"}`, InputValue: `'04:05:06 UTC'`, ExpectValue: `"04:05:06Z"`},
{ColumnType: `time with time zone`, ExpectType: `{"type":["string","null"],"format":"time"}`, InputValue: `'04:05:06.123 UTC'`, ExpectValue: `"04:05:06.123Z"`},
Expand Down Expand Up @@ -135,9 +127,7 @@ func TestDatatypes(t *testing.T) {
{ColumnType: `varchar(12) ARRAY`, ExpectType: fmt.Sprintf(arraySchemaPattern, `{"type":["string","null"]}`), InputValue: `{foo, bar}`, ExpectValue: `{"dimensions":[2],"elements":["foo","bar"]}`},
{ColumnType: `char(5) ARRAY`, ExpectType: fmt.Sprintf(arraySchemaPattern, `{"type":["string","null"]}`), InputValue: `{foo, bar}`, ExpectValue: `{"dimensions":[2],"elements":["foo ","bar "]}`},
{ColumnType: `cidr ARRAY`, ExpectType: fmt.Sprintf(arraySchemaPattern, `{"type":["string","null"]}`), InputValue: `{192.168.100.0/24, 2001:4f8:3:ba::/64}`, ExpectValue: `{"dimensions":[2],"elements":["192.168.100.0/24","2001:4f8:3:ba::/64"]}`},
{ColumnType: `date ARRAY`, ExpectType: fmt.Sprintf(arraySchemaPattern, `{"type":["string","null"],"format":"date-time"}`), InputValue: []interface{}{`2022-01-09`, `2022-01-10`}, ExpectValue: `{"dimensions":[2],"elements":["2022-01-09T00:00:00Z","2022-01-10T00:00:00Z"]}`},
// Replacement test for the previous one once "date_as_date" is the default
// {ColumnType: `date ARRAY`, ExpectType: fmt.Sprintf(arraySchemaPattern, `{"type":["string","null"],"format":"date"}`), InputValue: []interface{}{`2022-01-09`, `2022-01-10`}, ExpectValue: `{"dimensions":[2],"elements":["2022-01-09","2022-01-10"]}`},
{ColumnType: `date ARRAY`, ExpectType: fmt.Sprintf(arraySchemaPattern, `{"type":["string","null"],"format":"date"}`), InputValue: []interface{}{`2022-01-09`, `2022-01-10`}, ExpectValue: `{"dimensions":[2],"elements":["2022-01-09","2022-01-10"]}`},
{ColumnType: `double precision ARRAY`, ExpectType: fmt.Sprintf(arraySchemaPattern, `{"type":["number","string","null"],"format":"number"}`), InputValue: []interface{}{1.23, 4.56}, ExpectValue: `{"dimensions":[2],"elements":[1.23,4.56]}`},
{ColumnType: `inet ARRAY`, ExpectType: fmt.Sprintf(arraySchemaPattern, `{"type":["string","null"]}`), InputValue: []interface{}{`192.168.100.0/24`, `2001:4f8:3:ba::/64`}, ExpectValue: `{"dimensions":[2],"elements":["192.168.100.0/24","2001:4f8:3:ba::/64"]}`},
{ColumnType: `integer ARRAY`, ExpectType: fmt.Sprintf(arraySchemaPattern, `{"type":["integer","null"]}`), InputValue: []interface{}{1, 2, nil, 4}, ExpectValue: `{"dimensions":[4],"elements":[1,2,null,4]}`},
Expand Down
4 changes: 2 additions & 2 deletions source-postgres/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ var featureFlagDefaults = map[string]bool{

// When true, DATE columns are captured as YYYY-MM-DD dates. Historically these
// used to be captured as RFC3339 timestamps, which is usually not what users expect.
"date_as_date": false,
"date_as_date": true,

// When true, TIME WITHOUT TIME ZONE columns (also known as TIME) are captured as strings
// satisfying `format: time`. Historically these used to be captured as Unix microseconds,
// which is usually not what users expect.
"time_as_time": false,
"time_as_time": true,
}

// Validate checks that the configuration possesses all required properties.
Expand Down

0 comments on commit e5edd3e

Please sign in to comment.