Skip to content

Commit

Permalink
Change timestamp fieldType to be nullable (#184)
Browse files Browse the repository at this point in the history
* fix: Change timestamp fieldType to be nullable

Since datumParserTimestamp can return nil value, fieldType also should allow nil.
Without this, nil timestamp will be recognized as a strange timestamp, such as 1754-08-30 22:43:41 UTC (-6795364578871).

Follow-up: 4750ff8

* re-generate test data files

* remove deprecated package

Co-authored-by: Erik Sundell <[email protected]>
Co-authored-by: Sarah Zinger <[email protected]>
  • Loading branch information
3 people authored Sep 22, 2022
1 parent 4532619 commit 71cd89f
Show file tree
Hide file tree
Showing 15 changed files with 935 additions and 580 deletions.
5 changes: 3 additions & 2 deletions pkg/timestream/parsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func getFieldBuilder(t *timestreamquery.Type) (*fieldBuilder, error) {
switch *t.ScalarType {
case timestreamquery.ScalarTypeTimestamp:
return &fieldBuilder{
fieldType: data.FieldTypeTime,
fieldType: data.FieldTypeNullableTime,
parser: datumParserTimestamp,
}, nil
case timestreamquery.ScalarTypeBoolean:
Expand Down Expand Up @@ -212,7 +212,8 @@ func datumParserTimestamp(datum *timestreamquery.Datum) (interface{}, error) {
if datum.ScalarValue == nil {
return nil, nil
}
return time.Parse("2006-01-02 15:04:05.99999999", *datum.ScalarValue)
v, err := time.Parse("2006-01-02 15:04:05.99999999", *datum.ScalarValue)
return &v, err
}

func datumParserDate(datum *timestreamquery.Datum) (interface{}, error) {
Expand Down
174 changes: 91 additions & 83 deletions pkg/timestream/testdata/complex-timeseries.golden.txt

Large diffs are not rendered by default.

264 changes: 172 additions & 92 deletions pkg/timestream/testdata/complex-timeseries.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/timestream/testdata/describe-table.golden.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ Dimensions: 3 Fields by 17 Rows


====== TEST DATA RESPONSE (arrow base64) ======
FRAME=QVJST1cxAAD/////AAIAABAAAAAAAAoADgAMAAsABAAKAAAAFAAAA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1lAAAAAAAAAAAEAAQABAAAAAYAAABDb2x1bW4AADACAABBUlJPVzE=
28 changes: 14 additions & 14 deletions pkg/timestream/testdata/describe-table.json
Original file line number Diff line number Diff line change
Expand Up @@ -342,21 +342,21 @@
"ArrayValue": null,
"NullValue": null,
"RowValue": null,
"ScalarValue": "measure_value::double",
"ScalarValue": "measure_name",
"TimeSeriesValue": null
},
{
"ArrayValue": null,
"NullValue": null,
"RowValue": null,
"ScalarValue": "double",
"ScalarValue": "varchar",
"TimeSeriesValue": null
},
{
"ArrayValue": null,
"NullValue": null,
"RowValue": null,
"ScalarValue": "MEASURE_VALUE",
"ScalarValue": "MEASURE_NAME",
"TimeSeriesValue": null
}
]
Expand All @@ -367,21 +367,21 @@
"ArrayValue": null,
"NullValue": null,
"RowValue": null,
"ScalarValue": "measure_value::bigint",
"ScalarValue": "time",
"TimeSeriesValue": null
},
{
"ArrayValue": null,
"NullValue": null,
"RowValue": null,
"ScalarValue": "bigint",
"ScalarValue": "timestamp",
"TimeSeriesValue": null
},
{
"ArrayValue": null,
"NullValue": null,
"RowValue": null,
"ScalarValue": "MEASURE_VALUE",
"ScalarValue": "TIMESTAMP",
"TimeSeriesValue": null
}
]
Expand All @@ -392,14 +392,14 @@
"ArrayValue": null,
"NullValue": null,
"RowValue": null,
"ScalarValue": "measure_value::varchar",
"ScalarValue": "measure_value::double",
"TimeSeriesValue": null
},
{
"ArrayValue": null,
"NullValue": null,
"RowValue": null,
"ScalarValue": "varchar",
"ScalarValue": "double",
"TimeSeriesValue": null
},
{
Expand All @@ -417,21 +417,21 @@
"ArrayValue": null,
"NullValue": null,
"RowValue": null,
"ScalarValue": "measure_name",
"ScalarValue": "measure_value::bigint",
"TimeSeriesValue": null
},
{
"ArrayValue": null,
"NullValue": null,
"RowValue": null,
"ScalarValue": "varchar",
"ScalarValue": "bigint",
"TimeSeriesValue": null
},
{
"ArrayValue": null,
"NullValue": null,
"RowValue": null,
"ScalarValue": "MEASURE_NAME",
"ScalarValue": "MEASURE_VALUE",
"TimeSeriesValue": null
}
]
Expand All @@ -442,21 +442,21 @@
"ArrayValue": null,
"NullValue": null,
"RowValue": null,
"ScalarValue": "time",
"ScalarValue": "measure_value::varchar",
"TimeSeriesValue": null
},
{
"ArrayValue": null,
"NullValue": null,
"RowValue": null,
"ScalarValue": "timestamp",
"ScalarValue": "varchar",
"TimeSeriesValue": null
},
{
"ArrayValue": null,
"NullValue": null,
"RowValue": null,
"ScalarValue": "TIMESTAMP",
"ScalarValue": "MEASURE_VALUE",
"TimeSeriesValue": null
}
]
Expand Down
Loading

0 comments on commit 71cd89f

Please sign in to comment.