Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle problematic correlated columns group bys #296

Closed
beikov opened this issue Nov 19, 2016 · 1 comment
Closed

Handle problematic correlated columns group bys #296

beikov opened this issue Nov 19, 2016 · 1 comment

Comments

@beikov
Copy link
Member

beikov commented Nov 19, 2016

Since this is part of the implicit group by generation functionality I don't see this as a bug per se.
Almost all DBs except for PostgreSQL require that all columns from (complex) expressions need to be listed in GROUP BY although the (complex) expression containing these very columns is already listed in the GROUP BY clause. Try if we can workaround that by using select aliases or ordinales. If not, I am not sure how we could retain the same semantics. Any ideas?

@beikov beikov added this to the 1.2.0 milestone Jan 17, 2017
@beikov beikov self-assigned this Jan 17, 2017
@beikov
Copy link
Member Author

beikov commented Jan 17, 2017

Since this was required to work correctly for the SIZE to COUNT transformation, I implemented it.
Note that DB2, SQL Server and Oracle were problematic because

  • When parameters occur in an expression, the DBs can't match the expression because of potential different parameter values even if the parameters get the same values assigned
  • When a subquery occurs in an expression, the DBs fail to group by that per definition. Instead, surrounding expressions and correlated columns have to be put into the group by
  • When non-deterministic expressions are used like e.g. CURRENT_TIMESTAMP, SQL Server fails to group by that with a cryptic error

Additionally MySQL was problematic in the sense that the HAVING clause strictly required that all columns which are used in it's expressions to appear in the GROUP BY clause. Other databases could match more complex expressions like CASE WHEN and others which already appear in the GROUP BY and thus allow these expressions to be used in the HAVING clause.

beikov added a commit that referenced this issue Jan 17, 2017
@beikov beikov closed this as completed Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant