Skip to content
This repository was archived by the owner on Feb 21, 2024. It is now read-only.

Commit d114680

Browse files
authored
Add SQL3 test coverage for expressionagg.go (#2351)
FB-2045 aggregate{Avg,Min,Max}->Update now tested for DataTypeDecimal. {avg,min,max}PlanExpression->WithChildren now tested. percentilePlanExpression->{Evaluate,Plan,WithChildren} is not tested because percentile gets sent directly to PQL rather than getting planned and evaluated in SQL. aggregateLast->everything is not tested because Last is not yet completely implemented.
1 parent f12587f commit d114680

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

sql3/test/defs/defs_aggregate.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,22 @@ var avgTests = TableTest{
378378
),
379379
Compare: CompareExactUnordered,
380380
},
381+
{
382+
SQLs: sqls(
383+
"SELECT avg(d1) AS avg_rows FROM avg_test WHERE d1 > 10",
384+
),
385+
ExpHdrs: hdrs(
386+
hdr("avg_rows", featurebase.WireQueryField{
387+
Type: dax.BaseTypeDecimal + "(4)",
388+
BaseType: dax.BaseTypeDecimal,
389+
TypeInfo: map[string]interface{}{"scale": int64(4)},
390+
}),
391+
),
392+
ExpRows: rows(
393+
row(pql.NewDecimal(120000, 4)),
394+
),
395+
Compare: CompareExactUnordered,
396+
},
381397
{
382398
SQLs: sqls(
383399
"SELECT avg(len(s1)) AS avg_rows FROM avg_test",
@@ -498,10 +514,38 @@ var percentileTests = TableTest{
498514
hdr("p_rows", fldTypeDecimal2),
499515
),
500516
ExpRows: rows(
517+
// This should probably be (1200, 2), not (1000, 2).
518+
// TODO: look into this when investigating the percentile/WHERE bug.
501519
row(pql.NewDecimal(1000, 2)),
502520
),
503521
Compare: CompareExactUnordered,
504522
},
523+
{
524+
SQLs: sqls(
525+
"SELECT percentile(i1, 50) AS p_rows FROM percentile_test WHERE i1 < 13",
526+
),
527+
ExpHdrs: hdrs(
528+
hdr("p_rows", fldTypeInt),
529+
),
530+
ExpRows: rows(
531+
row(int64(12)),
532+
),
533+
Compare: CompareExactUnordered,
534+
},
535+
// This test is failing! It seems to be returning the count of elements < 13,
536+
// rather than processing them for percentile.
537+
//{
538+
// SQLs: sqls(
539+
// "SELECT percentile(d1, 50) AS p_rows FROM percentile_test WHERE d1 < 13",
540+
// ),
541+
// ExpHdrs: hdrs(
542+
// hdr("p_rows", fldTypeDecimal2),
543+
// ),
544+
// ExpRows: rows(
545+
// row(pql.NewDecimal(1200, 2)),
546+
// ),
547+
// Compare: CompareExactUnordered,
548+
//},
505549
},
506550
}
507551

@@ -654,6 +698,30 @@ var minmaxTests = TableTest{
654698
),
655699
Compare: CompareExactUnordered,
656700
},
701+
{
702+
SQLs: sqls(
703+
"SELECT min(d1) AS p_rows FROM minmax_test WHERE d1 > 10",
704+
),
705+
ExpHdrs: hdrs(
706+
hdr("p_rows", fldTypeDecimal2),
707+
),
708+
ExpRows: rows(
709+
row(pql.NewDecimal(1100, 2)),
710+
),
711+
Compare: CompareExactUnordered,
712+
},
713+
{
714+
SQLs: sqls(
715+
"SELECT max(d1) AS p_rows FROM minmax_test WHERE d1 < 13",
716+
),
717+
ExpHdrs: hdrs(
718+
hdr("p_rows", fldTypeDecimal2),
719+
),
720+
ExpRows: rows(
721+
row(pql.NewDecimal(1200, 2)),
722+
),
723+
Compare: CompareExactUnordered,
724+
},
657725
{
658726
SQLs: sqls(
659727
"select min(ts1) as min_val, max(ts1) as max_val from minmax_test",

0 commit comments

Comments
 (0)