Skip to content

parser/clickhouse: table functions in FROM (numbers(10), remote(...)) fail to parse #606

Closed

Description

@ajitpratap0

Summary

ClickHouse table functions in FROM, such as numbers(N), remote(...), file(...) and url(...), are rejected because function-call table references are enabled only for Snowflake, BigQuery and PostgreSQL.

Reproduction

gosqlx.ParseWithDialect(sql, keywords.DialectClickHouse) on main 61ca6c8:

SELECT * FROM numbers(10)               -> E2002 at 1:22 expected statement, got LPAREN
SELECT number FROM numbers(10) AS n     -> E2002 at 1:27 expected statement, got LPAREN
SELECT * FROM remote('host', db, tbl)   -> E2002 at 1:21 expected statement, got LPAREN
SELECT * FROM t, numbers(3)             -> E2002 at 1:25 expected statement, got LPAREN

Expected: each parses into a TableReference with TableFunc set, as generate_series(1,10) does in the PostgreSQL dialect.

Notes

  • pkg/sql/parser/pivot.go:295 supportsTableFunction() lists only Snowflake, BigQuery and PostgreSQL. The call site is pkg/sql/parser/select_subquery.go:121. Adding ClickHouse is probably enough to parse these. The default dialect also rejects FROM generate_series(1,10) g. Whether to enable it there is a separate decision.
  • These references are also dropped on render. That is filed separately (TableFunc arguments missing from SQL()/formatter output), and it should be fixed together with this one, or enabling ClickHouse will produce lossy output.

Found during review of #583.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions