Skip to content

Spark: TABLE t, VALUES ... AS t(a, b), DESC TABLE t (#13 onto the v0.63.0 branch) - #14

Merged
moshap-firebolt merged 2 commits into
firebolt/v0.63.0-patchesfrom
firebolt/table-and-values-on-0.63
Oct 3, 2026
Merged

moshap-firebolt merged 2 commits into
firebolt/v0.63.0-patchesfrom
firebolt/table-and-values-on-0.63

Conversation

@moshap-firebolt

@moshap-firebolt moshap-firebolt commented Oct 3, 2026 •

Copy link
Copy Markdown

#13 was squash-merged into firebolt/typed-numeric-suffixes, its stacked base, rather than into firebolt/v0.63.0-patches. This carries that squash commit (d642873) onto the 0.63 branch as a clean cherry-pick.

The cherry-pick's tree is byte-identical to 8c0c77d, the commit packdb master pins today. A second commit fixes a Bugbot finding: the VALUES alias was read after the whole query body, so an aliased VALUES beside UNION/EXCEPT/INTERSECT failed; it is now read where the VALUES operand is parsed.

Content, unchanged from #13:

  • supports_table_statement (Spark, Databricks, Hive): TABLE <name> parses as SELECT * FROM <name> in any query-body position, keeping the name's quoting.
  • supports_values_alias: VALUES ... AS t(a, b) becomes SELECT * FROM (VALUES ...) AS t(a, b), on either side of a set operation.
  • DESC [TABLE] [EXTENDED|FORMATTED] name stays a table describe instead of describing the query TABLE name.
  • parse_as_table takes a second name part only after a period.

…13)

* Spark: TABLE t as a statement, VALUES ... AS t(a, b) as a query body

Two dialect hooks, on for Spark, Databricks and Hive. supports_table_statement
lets a statement start with TABLE, which parse_query already reads as
SetExpr::Table. supports_values_alias reads a table alias with a column
list after a VALUES body and rewrites the body as SELECT * FROM (VALUES
...) AS t(a, b), since a bare SetExpr::Values has nowhere to carry the
alias; a reserved word after VALUES (UNION, ORDER, LIMIT) is not an alias.

* parse_as_table: take a second name part only after a period

It read three tokens unconditionally, so TABLE t ORDER BY a swallowed
ORDER BY and then failed on what followed; the statement form is the
first place a clause can follow the name.

* Spark: read TABLE t as SELECT * FROM t in every query-body position

The string-only SetExpr::Table drops identifier quoting and leaves
consumers to special-case it at the top level. Under
supports_table_statement, build a SELECT * over the parsed ObjectName
instead, so TABLE works on set-operation sides, in CTEs, INSERT and
CTAS, and keeps its quote style.

* Spark: DESC TABLE t describes the table, not the query TABLE t

With TABLE able to start a query, DESCRIBE TABLE t parsed as a describe
of that query, and DESCRIBE TABLE EXTENDED t took EXTENDED for the table
name. For DESC/DESCRIBE under supports_table_statement, a TABLE followed
by a name now goes straight to the describe-table form, which accepts
EXTENDED/FORMATTED after TABLE as Spark writes it and prints TABLE
first. DESCRIBE table (a table named table) and EXPLAIN are unchanged.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 30670de. Configure here.

Comment thread src/parser/mod.rs Outdated
The alias was read after the whole query body, by which point a set
operator had been consumed, so VALUES ... AS t(a) UNION ... failed.
Read it where the VALUES operand is parsed, the way TABLE is.
@moshap-firebolt
moshap-firebolt merged commit c98241e into firebolt/v0.63.0-patches Oct 3, 2026
21 checks passed
@moshap-firebolt
moshap-firebolt deleted the firebolt/table-and-values-on-0.63 branch October 5, 2026 18:24
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.

1 participant