mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
groupby test work
This commit is contained in:
parent
283b00c741
commit
6a42e1e6ed
1 changed files with 52 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
// groupby tests
|
||||
var groupByTests = TableTest{
|
||||
name: "groupby_test",
|
||||
Table: tbl(
|
||||
"groupby_test",
|
||||
srcHdrs(
|
||||
|
|
@ -26,10 +27,12 @@ var groupByTests = TableTest{
|
|||
srcRow(int64(4), int64(12), float64(12), string("12"), nil, []int64{2, 3}, int64(4)),
|
||||
srcRow(int64(5), int64(12), float64(12), string("12"), nil, []int64{1, 3}, int64(1)),
|
||||
srcRow(int64(6), int64(13), float64(13), string("13"), nil, []int64{1, 2, 3}, int64(6)),
|
||||
srcRow(int64(7), nil, nil, nil, nil, nil, nil),
|
||||
),
|
||||
),
|
||||
SQLTests: []SQLTest{
|
||||
{
|
||||
name: "groupby-int-orderby-incorrect-reference",
|
||||
SQLs: sqls(
|
||||
"SELECT COUNT(*), i1 FROM groupby_test group by i1 order by count(*) asc",
|
||||
"SELECT COUNT(_id), i1 FROM groupby_test group by i1 order by count(*) asc",
|
||||
|
|
@ -37,6 +40,7 @@ var groupByTests = TableTest{
|
|||
ExpErr: "column reference, alias reference or column position expected",
|
||||
},
|
||||
{
|
||||
name: "groupby-int-orderby-2",
|
||||
SQLs: sqls(
|
||||
"SELECT COUNT(*), i1 FROM groupby_test group by i1 order by 2 asc",
|
||||
"SELECT COUNT(_id), i1 FROM groupby_test group by i1 order by 2 asc",
|
||||
|
|
@ -54,6 +58,7 @@ var groupByTests = TableTest{
|
|||
Compare: CompareExactOrdered,
|
||||
},
|
||||
{
|
||||
name: "groupby-aliased-int-orderby-aliased-int",
|
||||
SQLs: sqls(
|
||||
"SELECT COUNT(*), i1 as c FROM groupby_test group by i1 order by c asc",
|
||||
"SELECT COUNT(_id), i1 as c FROM groupby_test group by i1 order by c asc",
|
||||
|
|
@ -71,6 +76,7 @@ var groupByTests = TableTest{
|
|||
Compare: CompareExactOrdered,
|
||||
},
|
||||
{
|
||||
name: "groupby-aliased-int-orderby-int",
|
||||
SQLs: sqls(
|
||||
"SELECT COUNT(*), i1 as c FROM groupby_test group by i1 order by i1 asc",
|
||||
"SELECT COUNT(_id), i1 as c FROM groupby_test group by i1 order by i1 asc",
|
||||
|
|
@ -88,6 +94,7 @@ var groupByTests = TableTest{
|
|||
Compare: CompareExactOrdered,
|
||||
},
|
||||
{
|
||||
name: "groupby-int",
|
||||
SQLs: sqls(
|
||||
"SELECT COUNT(*), i1 FROM groupby_test group by i1",
|
||||
"SELECT COUNT(_id), i1 FROM groupby_test group by i1",
|
||||
|
|
@ -105,6 +112,7 @@ var groupByTests = TableTest{
|
|||
Compare: CompareExactUnordered,
|
||||
},
|
||||
{
|
||||
name: "groupby-distinct-int2",
|
||||
SQLs: sqls(
|
||||
"SELECT COUNT(distinct i2) AS count_rows, i1 FROM groupby_test group by i1",
|
||||
),
|
||||
|
|
@ -121,6 +129,7 @@ var groupByTests = TableTest{
|
|||
Compare: CompareExactUnordered,
|
||||
},
|
||||
{
|
||||
name: "groupby-int-sum-i2",
|
||||
SQLs: sqls(
|
||||
"SELECT sum(i2) AS sum_rows, i1 FROM groupby_test group by i1",
|
||||
),
|
||||
|
|
@ -134,6 +143,7 @@ var groupByTests = TableTest{
|
|||
Compare: CompareExactUnordered,
|
||||
},
|
||||
{
|
||||
name: "groupby-int-count",
|
||||
SQLs: sqls(
|
||||
"SELECT COUNT(*) FROM groupby_test group by i1",
|
||||
),
|
||||
|
|
@ -149,6 +159,7 @@ var groupByTests = TableTest{
|
|||
Compare: CompareExactUnordered,
|
||||
},
|
||||
{
|
||||
name: "groupby-int-distinct-sum",
|
||||
SQLs: sqls(
|
||||
"select count(distinct i2) AS count_rows, sum(i2) as sum_rows, i1 from groupby_test group by i1",
|
||||
),
|
||||
|
|
@ -166,6 +177,7 @@ var groupByTests = TableTest{
|
|||
Compare: CompareExactUnordered,
|
||||
},
|
||||
{
|
||||
name: "groupby-int-average",
|
||||
SQLs: sqls(
|
||||
"select avg(i1) as avg_rows, i1 from groupby_test group by i1",
|
||||
),
|
||||
|
|
@ -186,6 +198,7 @@ var groupByTests = TableTest{
|
|||
Compare: CompareExactUnordered,
|
||||
},
|
||||
{
|
||||
name: "groupby-int-average-decimal",
|
||||
SQLs: sqls(
|
||||
"select avg(d1) as avg_rows, i1 from groupby_test group by i1",
|
||||
),
|
||||
|
|
@ -206,24 +219,28 @@ var groupByTests = TableTest{
|
|||
Compare: CompareExactUnordered,
|
||||
},
|
||||
{
|
||||
name: "groupby-percentile",
|
||||
SQLs: sqls(
|
||||
"select percentile(i1, 0) as p_rows, i1 from groupby_test group by i1",
|
||||
),
|
||||
ExpErr: "aggregate 'PERCENTILE()' not allowed in GROUP BY",
|
||||
},
|
||||
{
|
||||
name: "groupby-min",
|
||||
SQLs: sqls(
|
||||
"select min(i1) as p_rows, i1 from groupby_test group by i1",
|
||||
),
|
||||
ExpErr: "aggregate 'MIN()' not allowed in GROUP BY",
|
||||
},
|
||||
{
|
||||
name: "groupby-max",
|
||||
SQLs: sqls(
|
||||
"select max(i1) as p_rows, i1 from groupby_test group by i1",
|
||||
),
|
||||
ExpErr: "aggregate 'MAX()' not allowed in GROUP BY",
|
||||
},
|
||||
{
|
||||
name: "groupby-intset",
|
||||
SQLs: sqls(
|
||||
"SELECT COUNT(*), is1 FROM groupby_test group by is1",
|
||||
),
|
||||
|
|
@ -239,6 +256,7 @@ var groupByTests = TableTest{
|
|||
Compare: CompareExactOrdered,
|
||||
},
|
||||
{
|
||||
name: "groupby-id",
|
||||
SQLs: sqls(
|
||||
"SELECT COUNT(*), id1 FROM groupby_test group by id1",
|
||||
),
|
||||
|
|
@ -255,5 +273,39 @@ var groupByTests = TableTest{
|
|||
),
|
||||
Compare: CompareExactOrdered,
|
||||
},
|
||||
{
|
||||
name: "groupby-string",
|
||||
SQLs: sqls(
|
||||
"SELECT COUNT(*), s1 FROM groupby_test group by s1",
|
||||
),
|
||||
ExpHdrs: hdrs(
|
||||
hdr("", fldTypeInt),
|
||||
hdr("s1", fldTypeString),
|
||||
),
|
||||
ExpRows: rows(
|
||||
row(int64(2), string("10")),
|
||||
row(int64(1), string("11")),
|
||||
row(int64(2), string("12")),
|
||||
row(int64(1), string("13")),
|
||||
),
|
||||
Compare: CompareExactOrdered,
|
||||
},
|
||||
{
|
||||
name: "groupby-string-orderby-str-desc",
|
||||
SQLs: sqls(
|
||||
"SELECT COUNT(*), s1 FROM groupby_test group by s1 order by s1 desc",
|
||||
),
|
||||
ExpHdrs: hdrs(
|
||||
hdr("", fldTypeInt),
|
||||
hdr("s1", fldTypeString),
|
||||
),
|
||||
ExpRows: rows(
|
||||
row(int64(1), string("13")),
|
||||
row(int64(2), string("12")),
|
||||
row(int64(1), string("11")),
|
||||
row(int64(2), string("10")),
|
||||
),
|
||||
Compare: CompareExactOrdered,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue