Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
200ddcd
do not add GetField extra columns for aggregate functions in having c…
angelamayxie Aug 15, 2025
8cbf652
renamed SelectedExprs to selectDeps, use projections as selectedExprs…
angelamayxie Aug 15, 2025
f9ee326
add child of alias in group by clauses to groupbys map
angelamayxie Aug 15, 2025
dc04c1e
exclude alias dependencies from select expressions
angelamayxie Aug 15, 2025
de8d2b7
rename variables
angelamayxie Aug 15, 2025
7fbc47e
fix queries that aren't valid in mysql
angelamayxie Aug 16, 2025
0787112
add join filters to group by expressions
angelamayxie Aug 18, 2025
afb7521
passing all tests except query plan tests
angelamayxie Aug 18, 2025
0ced51a
regenerated query plans
angelamayxie Aug 18, 2025
fc116d4
updated broken queries
angelamayxie Aug 19, 2025
32d9308
[ga-format-pr] Run ./format_repo.sh to fix formatting
angelamayxie Aug 19, 2025
0845c07
clean up
angelamayxie Aug 19, 2025
78a9bdc
Merge branch 'angela/groupby' of https://github.com/dolthub/go-mysql-…
angelamayxie Aug 19, 2025
c489263
added docstrings and removed checking for equals dependencies in havi…
angelamayxie Aug 19, 2025
2a2e241
Merge branch 'main' of https://github.com/dolthub/go-mysql-server int…
angelamayxie Aug 19, 2025
c67b51a
updated parse test plans
angelamayxie Aug 19, 2025
694aad9
updated json test query
angelamayxie Aug 19, 2025
a9c0bfa
move group by validation to before filters get pushed down
angelamayxie Aug 19, 2025
171faa5
update validation rules test
angelamayxie Aug 19, 2025
ab48438
Merge branch 'main' into angela/groupby
angelamayxie Aug 19, 2025
69276a3
[ga-format-pr] Run ./format_repo.sh to fix formatting
angelamayxie Aug 19, 2025
3b70009
update variable names
angelamayxie Aug 19, 2025
9f49c56
make error message more similar to mysql error message
angelamayxie Aug 19, 2025
d36ce8b
added docstring for WithAliasDeps
angelamayxie Aug 20, 2025
5943a32
Merge branch 'main' of https://github.com/dolthub/go-mysql-server int…
angelamayxie Aug 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 1 addition & 37 deletions enginetest/enginetests.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,43 +866,7 @@ func TestOrderByGroupBy(t *testing.T, harness Harness) {
}
require.Equal(t, rowCount, 3)

// TODO: this should error; the order by doesn't count towards ONLY_FULL_GROUP_BY
_, rowIter, _, err = e.Query(ctx, "select id, team from members group by team order by id")
require.NoError(t, err)
rowCount = 0
for {
row, err = rowIter.Next(ctx)
if err == io.EOF {
break
}
rowCount++
require.NoError(t, err)

var val int64
switch v := row[0].(type) {
case int64:
val = v
case int32:
val = int64(v)
default:
panic(fmt.Sprintf("unexpected type %T", v))
}

team, ok, err := sql.Unwrap[string](ctx, row[1])
require.True(t, ok)
require.NoError(t, err)
switch team {
case "red":
require.True(t, val == 3 || val == 4)
case "orange":
require.True(t, val == 5 || val == 6 || val == 7)
case "purple":
require.True(t, val == 8)
default:
panic("received non-existent team")
}
}
require.Equal(t, rowCount, 3)
AssertErr(t, e, harness, "select id, team from members group by team order by id", nil, analyzererrors.ErrValidationGroupBy)
})
}

Expand Down
2 changes: 1 addition & 1 deletion enginetest/join_planning_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ order by 1;`,
},
{
// group by doesn't transform
q: "select * from xy where y-1 in (select u from uv group by v having v = 2 order by 1) order by 1;",
q: "select * from xy where y-1 in (select u from uv group by u having u = 2 order by 1) order by 1;",
types: []plan.JoinType{plan.JoinTypeSemi},
exp: []sql.Row{{3, 3}},
},
Expand Down
46 changes: 21 additions & 25 deletions enginetest/queries/column_alias_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ var ColumnAliasQueries = []ScriptTest{
Query: "SELECT 1 as a, (select a) as b;",
Expected: []sql.Row{{1, 1}},
},
{
Query: `SELECT 1 as a, (select a union select a) as b;`,
Expected: []sql.Row{{1, 1}},
},
{
Query: "SELECT 1 as a, (select a) as b from dual;",
Expected: []sql.Row{{1, 1}},
Expand All @@ -226,6 +230,22 @@ var ColumnAliasQueries = []ScriptTest{
Query: "SELECT 1 as a, (select a) from xy;",
Expected: []sql.Row{{1, 1}, {1, 1}, {1, 1}, {1, 1}},
},
{
// https://github.com/dolthub/dolt/issues/4256
Query: `SELECT *, (select i union select i) as a from mytable;`,
Expected: []sql.Row{
{1, "first row", 1},
{2, "second row", 2},
{3, "third row", 3}},
},
{
Query: "select 1 as b, (select b group by b order by b) order by 1;",
Expected: []sql.Row{{1, 1}},
},
{
Query: `select 1 as a, (select b), 0 as b;`,
ExpectedErr: sql.ErrColumnNotFound,
},
},
},
{
Expand All @@ -245,39 +265,15 @@ var ColumnAliasQueries = []ScriptTest{
},
{
Name: "various broken alias queries",
Skip: true,
Assertions: []ScriptTestAssertion{
{
// The second query in the union subquery returns "x" instead of mytable.i
// https://github.com/dolthub/dolt/issues/4256
Query: `SELECT *, (select i union select i) as a from mytable;`,
Expected: []sql.Row{
{1, "first row", 1},
{2, "second row", 2},
{3, "third row", 3}},
},
{
Query: `SELECT 1 as a, (select a union select a) as b;`,
Expected: []sql.Row{{1, 1}},
},
{
// GMS executes this query, but it is not valid because of the forward ref of alias b.
// GMS should return an error about an invalid forward-ref.
Skip: true,
Query: `select 1 as a, (select b), 0 as b;`,
ExpectedErr: sql.ErrColumnNotFound,
},
{
// GMS returns "expression 'dt.two' doesn't appear in the group by expressions", but MySQL will execute
// this query.
Query: "select 1 as a, one + 1 as mod1, dt.* from mytable as t1, (select 1, 2 from mytable) as dt (one, two) where dt.one > 0 group by one;",
// column names: a, mod1, one, two
Expected: []sql.Row{{1, 2, 1, 2}},
},
{
// GMS returns `ambiguous column or alias name "b"` on both cases of `group by b` and `group by 1` inside subquery, but MySQL executes.
Query: "select 1 as b, (select b group by b order by b) order by 1;",
Expected: []sql.Row{{1, 1}},
},
},
},
}
452 changes: 226 additions & 226 deletions enginetest/queries/imdb_plans.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions enginetest/queries/information_schema_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var InfoSchemaQueries = []QueryTest{
table_name, index_name, comment, non_unique, GROUP_CONCAT(column_name ORDER BY seq_in_index) AS COLUMNS
FROM information_schema.statistics
WHERE table_schema='mydb' AND table_name='mytable' AND index_name!="PRIMARY"
GROUP BY index_name;`,
GROUP BY index_name, comment, non_unique;`,
ExpectedColumns: sql.Schema{
{
Name: "TABLE_NAME",
Expand Down Expand Up @@ -274,7 +274,7 @@ var InfoSchemaQueries = []QueryTest{
WHERE FILE_TYPE = 'UNDO LOG'
AND FILE_NAME IS NOT NULL
AND LOGFILE_GROUP_NAME IS NOT NULL
GROUP BY LOGFILE_GROUP_NAME, FILE_NAME, ENGINE, TOTAL_EXTENTS, INITIAL_SIZE
GROUP BY LOGFILE_GROUP_NAME, FILE_NAME, ENGINE, TOTAL_EXTENTS, INITIAL_SIZE, EXTRA
ORDER BY LOGFILE_GROUP_NAME
`,
Expected: nil,
Expand Down
Loading
Loading