From 6121541743f9d73fd9533f3f0f6932299c3fc829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= Date: Wed, 31 Jan 2024 16:49:46 +0000 Subject: [PATCH] checkJSONValue: error on empty results --- flow/e2e/bigquery/peer_flow_bq_test.go | 4 ++++ flow/e2e/snowflake/qrep_flow_sf_test.go | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/flow/e2e/bigquery/peer_flow_bq_test.go b/flow/e2e/bigquery/peer_flow_bq_test.go index 17cd3ecbea..e180e215eb 100644 --- a/flow/e2e/bigquery/peer_flow_bq_test.go +++ b/flow/e2e/bigquery/peer_flow_bq_test.go @@ -81,6 +81,10 @@ func (s PeerFlowE2ETestSuiteBQ) checkJSONValue(tableName, colName, fieldName, va return fmt.Errorf("json value check failed: %v", err) } + if len(res.Records) == 0 { + return fmt.Errorf("bad json: empty result set from %s", tableName) + } + jsonVal := res.Records[0][0].Value if jsonVal != value { return fmt.Errorf("bad json value in field %s of column %s: %v. expected: %v", fieldName, colName, jsonVal, value) diff --git a/flow/e2e/snowflake/qrep_flow_sf_test.go b/flow/e2e/snowflake/qrep_flow_sf_test.go index ad47232b1e..9541d61c86 100644 --- a/flow/e2e/snowflake/qrep_flow_sf_test.go +++ b/flow/e2e/snowflake/qrep_flow_sf_test.go @@ -19,13 +19,15 @@ func (s PeerFlowE2ETestSuiteSF) setupSourceTable(tableName string, numRows int) } func (s PeerFlowE2ETestSuiteSF) checkJSONValue(tableName, colName, fieldName, value string) error { - res, err := s.sfHelper.ExecuteAndProcessQuery(fmt.Sprintf( - "SELECT %s:%s FROM %s;", - colName, fieldName, tableName)) + res, err := s.sfHelper.ExecuteAndProcessQuery(fmt.Sprintf("SELECT %s:%s FROM %s", colName, fieldName, tableName)) if err != nil { return fmt.Errorf("json value check failed: %v", err) } + if len(res.Records) == 0 { + return fmt.Errorf("bad json: empty result set from %s", tableName) + } + jsonVal := res.Records[0][0].Value if jsonVal != value { return fmt.Errorf("bad json value in field %s of column %s: %v. expected: %v", fieldName, colName, jsonVal, value)