Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for Date in QRep #982

Merged
merged 3 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions flow/connectors/bigquery/qrep_avro_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ func getTransformedColumns(dstTableMetadata *bigquery.TableMetadata, syncedAtCol
case bigquery.JSONFieldType:
transformedColumns = append(transformedColumns,
fmt.Sprintf("PARSE_JSON(`%s`) AS `%s`", col.Name, col.Name))
case bigquery.DateFieldType:
transformedColumns = append(transformedColumns,
fmt.Sprintf("CAST(`%s` AS DATE) AS `%s`", col.Name, col.Name))
default:
transformedColumns = append(transformedColumns, fmt.Sprintf("`%s`", col.Name))
}
Expand Down
6 changes: 4 additions & 2 deletions flow/e2e/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ func CreateTableForQRep(pool *pgxpool.Pool, suffix string, tableName string) err
"f6 jsonb",
"f7 jsonb",
"f8 smallint",
"my_date DATE",
}
if strings.Contains(tableName, "sf") || strings.Contains(tableName, "bq") {
tblFields = append(tblFields, `"geometryPoint" geometry(point)`,
Expand Down Expand Up @@ -282,7 +283,7 @@ func PopulateSourceTable(pool *pgxpool.Pool, suffix string, tableName string, ro
CURRENT_TIMESTAMP, 1, ARRAY['text1', 'text2'], ARRAY[123, 456], ARRAY[789, 012],
ARRAY['varchar1', 'varchar2'], '{"key": 8.5}',
'[{"key1": "value1", "key2": "value2", "key3": "value3"}]',
'{"key": "value"}', 15 %s
'{"key": "value"}', 15, '2023-08-08' %s
Amogh-Bharadwaj marked this conversation as resolved.
Show resolved Hide resolved
)`,
id, uuid.New().String(), uuid.New().String(),
uuid.New().String(), uuid.New().String(), uuid.New().String(), uuid.New().String(), geoValues)
Expand All @@ -303,7 +304,7 @@ func PopulateSourceTable(pool *pgxpool.Pool, suffix string, tableName string, ro
deal_id, ethereum_transaction_id, ignore_price, card_eth_value,
paid_eth_price, card_bought_notified, address, account_id,
asset_id, status, transaction_id, settled_at, reference_id,
settle_at, settlement_delay_reason, f1, f2, f3, f4, f5, f6, f7, f8
settle_at, settlement_delay_reason, f1, f2, f3, f4, f5, f6, f7, f8, my_date
%s
) VALUES %s;
`, suffix, tableName, geoColumns, strings.Join(rows, ",")))
Expand Down Expand Up @@ -424,6 +425,7 @@ func GetOwnersSchema() *model.QRecordSchema {
{Name: "f6", Type: qvalue.QValueKindJSON, Nullable: true},
{Name: "f7", Type: qvalue.QValueKindJSON, Nullable: true},
{Name: "f8", Type: qvalue.QValueKindInt16, Nullable: true},
{Name: "my_date", Type: qvalue.QValueKindDate, Nullable: true},
{Name: "geometryPoint", Type: qvalue.QValueKindGeometry, Nullable: true},
{Name: "geometry_linestring", Type: qvalue.QValueKindGeometry, Nullable: true},
{Name: "geometry_polygon", Type: qvalue.QValueKindGeometry, Nullable: true},
Expand Down
Loading