Skip to content

Conversation

@jycor
Copy link
Contributor

@jycor jycor commented Apr 6, 2023

Comment on lines 111 to 119
// add to plan.GroupBy.SelectedExprs iff expression has an expression.GetField
hasGetField := false
transform.InspectExpr(e, func(expr sql.Expression) bool {
if _, ok := expr.(*expression.GetField); ok {
hasGetField = true
return true
}
return false
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// add to plan.GroupBy.SelectedExprs iff expression has an expression.GetField
hasGetField := false
transform.InspectExpr(e, func(expr sql.Expression) bool {
if _, ok := expr.(*expression.GetField); ok {
hasGetField = true
return true
}
return false
})
// add to plan.GroupBy.SelectedExprs iff expression has an expression.GetField
hasGetField = transform.InspectExpr(e, func(expr sql.Expression) bool {
_, ok := expr.(*expression.GetField)
return ok
})

" └─ columns: [a]\n" +
"",
},
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add some tests 1) with this transform preformed inside subqueries, making sure they stay cached afterwards (select * from xy join (select count(*) as u, 1 as v from ...) uv on x = u, and 2)) this transform performed inside subquery expressions, with semi/anti joins still being generated afterwards ( select ... where x in/not in (select y from (select count(*) as u, 1 as v from ...) uv), select ... where x =/!= (...), select * from xy where exists (select y from (select count(*) as u, 1 as v from ...) uv) where x = y))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and idk if this is valid, but can the projection be a subquery expression? select count(*), (select * from uv where u = x) from xy group by x

return n, transform.SameTree, nil
}
if !ok || len(g.GroupByExprs) == 0 {
if !ok || len(g.GroupByExprs) == 0 { // TODO: this never happens because of above if???
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the TODO action here?
If the "never happens" situation actually happens, how bad is it? Should we return an error or panic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just a note for myself while I was looking through the code.
If we somehow make it to this condition and it evaluates to true, we would just do what we did in the previous block.

I'm pretty sure this block can be safely removed

Copy link
Contributor

@max-hoffman max-hoffman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants