Skip to content

Commit

Permalink
count distinct tests, tighten bounds, ignore task count
Browse files Browse the repository at this point in the history
  • Loading branch information
gfr10598 committed Feb 21, 2019
1 parent 703c159 commit 6cf9dc8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions cloud/bq/sanity.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,22 @@ 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 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)

// TODO - this should take a context?
err := dsExt.QueryAndParse(ctx, queryString, &detail)
if err != nil {
log.Println(err)
log.Println("Query error:", queryString)
log.Println("Query:", queryString)
}
return &detail, err
}
Expand Down
6 changes: 3 additions & 3 deletions cloud/bq/sanity_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestGetTableDetail(t *testing.T) {
if err != nil {
t.Error(err)
} else if detail.TaskFileCount != 2 || detail.TestCount != 4 {
t.Error("Wrong number of tasks or tests")
t.Errorf("Wrong number of tasks or tests %v\n", detail)
}

srcDS, err := dataset.NewDataset(ctx, "mlab-testing", "src")
Expand All @@ -50,8 +50,8 @@ func TestGetTableDetail(t *testing.T) {
detail, err = bq.GetTableDetail(ctx, &srcDS, srcDS.Table("DedupTest_19990101"))
if err != nil {
t.Error(err)
} else if detail.TaskFileCount != 2 || detail.TestCount != 6 {
t.Error("Wrong number of tasks or tests")
} else if detail.TaskFileCount != 2 || detail.TestCount != 4 {
t.Errorf("Wrong number of tasks or tests %v\n", detail)
}
}

Expand Down

0 comments on commit 6cf9dc8

Please sign in to comment.