From e15b1c904fc30a2e54abf9029497900b49f690ff Mon Sep 17 00:00:00 2001 From: Greg Russell Date: Tue, 30 Apr 2019 20:39:09 -0400 Subject: [PATCH 1/3] fix table detail query --- cloud/bq/sanity.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/cloud/bq/sanity.go b/cloud/bq/sanity.go index 2f6b7707..8226d98d 100644 --- a/cloud/bq/sanity.go +++ b/cloud/bq/sanity.go @@ -168,16 +168,10 @@ func GetTableDetail(ctx context.Context, dsExt *dataset.Dataset, table bqiface.T detail := Detail{} queryString := fmt.Sprintf(` #standardSQL - SELECT SUM(tests) AS TestCount, COUNT(DISTINCT task)-1 AS TaskFileCount - FROM ( - -- This avoids null counts when the partition doesn't exist or is empty. - SELECT 0 AS tests, "fake-task" AS task - UNION ALL - SELECT COUNT(DISTINCT test_id) AS tests, task_filename AS task - FROM `+"`%s.%s`"+` - %s -- where clause - GROUP BY task - )`, dataset, tableName, where) + SELECT COUNT(DISTINCT test_id) AS TestCount, COUNT(DISTINCT task_filename) AS TaskFileCount + FROM `+"`%s.%s`"+` + %s -- where clause + GROUP BY task`, dataset, tableName, where) // TODO - this should take a context? err := dsExt.QueryAndParse(ctx, queryString, &detail) From ba2bfdc15e526f87dca8a94acfebaa1589fd3c0d Mon Sep 17 00:00:00 2001 From: Greg Russell Date: Tue, 30 Apr 2019 20:57:45 -0400 Subject: [PATCH 2/3] remove GROUP BY --- cloud/bq/sanity.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloud/bq/sanity.go b/cloud/bq/sanity.go index 8226d98d..52f191fc 100644 --- a/cloud/bq/sanity.go +++ b/cloud/bq/sanity.go @@ -170,8 +170,8 @@ func GetTableDetail(ctx context.Context, dsExt *dataset.Dataset, table bqiface.T #standardSQL SELECT COUNT(DISTINCT test_id) AS TestCount, COUNT(DISTINCT task_filename) AS TaskFileCount FROM `+"`%s.%s`"+` - %s -- where clause - GROUP BY task`, dataset, tableName, where) + %s -- where clause`, + dataset, tableName, where) // TODO - this should take a context? err := dsExt.QueryAndParse(ctx, queryString, &detail) From 0fc1ea2934550801e414a9421d9df70e612c2c6b Mon Sep 17 00:00:00 2001 From: Greg Russell Date: Tue, 30 Apr 2019 20:59:54 -0400 Subject: [PATCH 3/3] remove obsolete TODOs --- cloud/bq/sanity.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cloud/bq/sanity.go b/cloud/bq/sanity.go index 52f191fc..058c04a4 100644 --- a/cloud/bq/sanity.go +++ b/cloud/bq/sanity.go @@ -107,8 +107,6 @@ func (at *AnnotatedTable) CachedDetail(ctx context.Context) (*Detail, error) { if ctx == nil { return nil, ErrNilContext } - // TODO - use context - // TODO - maybe just embed code here. at.detail, at.err = GetTableDetail(ctx, at.dataset, at.Table) if at.err != nil { log.Println(at.FullyQualifiedName(), at.TableID()) @@ -130,8 +128,6 @@ func (at *AnnotatedTable) CachedPartitionInfo(ctx context.Context) (*dataset.Par if ctx == nil { return nil, ErrNilContext } - // TODO - use context - // TODO - maybe just embed code here. at.pInfo, at.err = at.GetPartitionInfo(ctx) return at.pInfo, at.err } @@ -173,7 +169,6 @@ func GetTableDetail(ctx context.Context, dsExt *dataset.Dataset, table bqiface.T %s -- where clause`, dataset, tableName, where) - // TODO - this should take a context? err := dsExt.QueryAndParse(ctx, queryString, &detail) if err != nil { log.Println(err)