Skip to content

bug: Do not use Positional Arguments in ClickHouse GROUP BY #6101

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

Closed
1 task done
JackFielding opened this issue Apr 27, 2023 · 0 comments · Fixed by #6106
Closed
1 task done

bug: Do not use Positional Arguments in ClickHouse GROUP BY #6101

JackFielding opened this issue Apr 27, 2023 · 0 comments · Fixed by #6106
Assignees
Labels
feature Features or general enhancements

Comments

@JackFielding
Copy link
Contributor

JackFielding commented Apr 27, 2023

Is your feature request related to a problem?

It would be preferable if the generated ClickHouse SQL did not use positional arguments for GROUP BY, e.g. GROUP BY 1, 2 and used the columns names instead, e.g. GROUP BY col_1, col_2.

Using positional arguments rather than named arguments has the following inconveniences:

  • The generated SQL queries are invalid for ClickHouse versions prior to 21.10. I regularly use old versions like this.
  • For ClickHouse versions from 21.10 but before 22.7 the user must explicitly specify the enable_positional_arguments setting otherwise the queries are invalid. e.g. pass settings={"enable_positional_arguments": True} to the backend.

Using named rather than positional arguments would be valid in all ClickHouse versions.

In the discussion: #6099 I had a go at hacking the code and found what appeared to be a solution.

Describe the solution you'd like

As per: #6099. Using the code:

import ibis

t = ibis.table(dict(a="int", b="str", c="str"), name="t")
expr = t.group_by(["b", "c"]).agg(t["a"].sum().name("hi"))
ibis.show_sql(expr, dialect="clickhouse")

instead of generating the query:

SELECT
  t0.b,
  t0.c,
  SUM(t0.a) AS hi
FROM t AS t0
GROUP BY
  1,
  2

it would be preferable if ibis generated the query:

SELECT
  t0.b,
  t0.c,
  SUM(t0.a) AS hi
FROM t AS t0
GROUP BY
  t0.b,
  t0.c

What version of ibis are you running?

5.0.1

What backend(s) are you using, if any?

ClickHouse

Code of Conduct

  • I agree to follow this project's Code of Conduct
@JackFielding JackFielding added the feature Features or general enhancements label Apr 27, 2023
@JackFielding JackFielding changed the title feat: Do not use Positional Arguments in ClickHouse GROUP BY bug: Do not use Positional Arguments in ClickHouse GROUP BY Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Features or general enhancements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant