Skip to content

Commit a49d4f0

Browse files
author
James Cor
committed
docstring
1 parent bba536d commit a49d4f0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sql/planbuilder/factory.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ func (f *factory) buildTableAlias(name string, child sql.Node) (plan.TableIdNode
178178
}
179179
}
180180

181+
182+
// buildDistinct will wrap the child node in a distinct node depending on the Sort nodes and Projections there.
183+
// if the sort fields are a subset of the projection fields
184+
// sort(project(table)) -> sort(distinct(project(table)))
185+
// else
186+
// sort(project(table)) -> distinct(sort(project(table)))
181187
func (f *factory) buildDistinct(child sql.Node) sql.Node {
182188
if proj, isProj := child.(*plan.Project); isProj {
183189
// TODO: if projection columns are just primary key, distinct is no-op

0 commit comments

Comments
 (0)