Skip to content

DuckDB, MySQL, Spark, Databricks, Hive, ClickHouse: Accept string literal aliases only where each engine does - #2669

Open
LucaCappelletti94 wants to merge 1 commit into
mainfrom
string-alias-per-engine
Open

LucaCappelletti94 wants to merge 1 commit into
mainfrom
string-alias-per-engine

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

Follow-up to #2668, which this PR is stacked on.

Engines differ on single-quoted string aliases. SQLite 3.51.1 accepts SELECT 1 AS 'x', SELECT 1 'x', FROM t AS 'y' and FROM t 'y'. DuckDB 1.4.4 accepts only the two forms with AS. MySQL accepts a string as a column alias but not as a table alias (select_alias against opt_table_alias in https://github.com/mysql/mysql-server/blob/trunk/sql/sql_yacc.yy). Spark (namedExpression and tableAlias in https://github.com/apache/spark/blob/master/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4), Hive (selectItem and tableAlias) and ClickHouse (ParserAlias only takes identifiers, https://clickhouse.com/docs/reference/syntax#identifiers) accept none of them. Every one of these dialects accepted all four forms.

supports_string_literal_alias is replaced by supports_string_literal_column_alias and supports_string_literal_table_alias, each told whether the alias follows AS. Both default to true, so dialects whose engines were not checked are unchanged. A per-engine test pins all four forms for PostgreSQL, SQLite, DuckDB, MySQL, Spark, Databricks, Hive and ClickHouse, and a capability-driven test checks every dialect against the exact errors.

I used Opus in support of this PR to try and include all relevant dialects, I checked the various documentations it found and they seem correct to me.

@codecov-commenter

codecov-commenter commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15385% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.32%. Comparing base (d32825d) to head (560faf2).

Files with missing lines Patch % Lines
src/parser/mod.rs 81.81% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2669      +/-   ##
==========================================
+ Coverage   81.29%   81.32%   +0.02%     
==========================================
  Files          42       42              
  Lines       33950    33994      +44     
  Branches    33950    33994      +44     
==========================================
+ Hits        27601    27645      +44     
  Misses       2785     2785              
  Partials     3564     3564              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Base automatically changed from upstream/postgres-no-string-alias to main October 18, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants