Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 93014cf

Browse files
committed
analyzer: do not erase sort node when pushing it down
Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
1 parent 1783e90 commit 93014cf

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

engine_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,6 +2536,12 @@ func TestOrderByGroupBy(t *testing.T) {
25362536
require.NoError(err)
25372537

25382538
require.Equal(expected, rows)
2539+
2540+
_, _, err = e.Query(
2541+
newCtx(),
2542+
"SELECT team, COUNT(*) FROM members GROUP BY team ORDER BY columndoesnotexist",
2543+
)
2544+
require.Error(err)
25392545
}
25402546

25412547
func TestTracing(t *testing.T) {

sql/analyzer/resolve_orderby.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func pushSortDown(sort *plan.Sort) (sql.Node, error) {
164164
plan.NewSort(sort.SortFields, child.Child),
165165
), nil
166166
case *plan.ResolvedTable:
167-
return child, nil
167+
return sort, nil
168168
default:
169169
children := child.Children()
170170
if len(children) == 1 {

0 commit comments

Comments
 (0)