Skip to content

Databricks: support CREATE TABLE USING, MAP<K, V> columns and LONG as BIGINT - #2425

Open
shuvamk wants to merge 1 commit into
apache:mainfrom
shuvamk:databricks-spark-sql-flags
Open

Databricks: support CREATE TABLE USING, MAP<K, V> columns and LONG as BIGINT#2425
shuvamk wants to merge 1 commit into
apache:mainfrom
shuvamk:databricks-spark-sql-flags

Conversation

@shuvamk

@shuvamk shuvamk commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Databricks SQL is built on Spark SQL, but DatabricksDialect never got three of the flags SparkSqlDialect sets. These fail on DatabricksDialect and parse on SparkSqlDialect:

CREATE TABLE t (id BIGINT) USING DELTA
CREATE TABLE t (m MAP<STRING, INT>)

with Expected: end of statement, found: USING at Line: 1, Column: 28 and Expected: ',' or ')' after column definition, found: < at Line: 1, Column: 22.

CREATE TABLE t (id LONG) parses, but builds a DataType::Custom holding LONG instead of DataType::BigInt(None). Databricks gives the type as { BIGINT | LONG }https://docs.databricks.com/aws/en/sql/language-manual/data-types/bigint-type

The fix sets those three flags on DatabricksDialect, mirroring src/dialect/spark.rs. No parser change, no other dialect affected.

Tests are in tests/sqlparser_databricks.rs and all three fail with src/dialect/databricks.rs reverted. The AGENTS.md pre-commit checks are clean locally.

… BIGINT

Databricks SQL is built on Spark SQL, but DatabricksDialect never got
three of the flags SparkSqlDialect sets, so these fail on Databricks and
parse on Spark:

    CREATE TABLE t (id BIGINT) USING DELTA
    CREATE TABLE t (m MAP<STRING, INT>)

with "Expected: end of statement, found: USING at Line: 1, Column: 28"
and "Expected: ',' or ')' after column definition, found: < at Line: 1,
Column: 22".

CREATE TABLE t (id LONG) parses, but builds DataType::Custom("LONG")
instead of DataType::BigInt(None). Databricks documents the type as
{ BIGINT | LONG }.

Set supports_create_table_using, supports_long_type_as_bigint and
supports_map_literal_with_angle_brackets on DatabricksDialect, mirroring
src/dialect/spark.rs. No parser change and no other dialect is affected.

Regression tests in tests/sqlparser_databricks.rs; all three fail with
src/dialect/databricks.rs reverted.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

databricks().verified_stmt("CREATE TABLE IF NOT EXISTS t (id BIGINT) USING PARQUET");

assert!(all_dialects_where(|d| !d.supports_create_table_using())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider adding the analogous assert also for the other flags you have set


databricks().verified_stmt("CREATE TABLE IF NOT EXISTS t (id BIGINT) USING PARQUET");

assert!(all_dialects_where(|d| !d.supports_create_table_using())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, I believe that since this assertion regards all dialects except databricks, it should not be in the databricks tests, but in common.

Comment thread src/dialect/databricks.rs
fn supports_long_type_as_bigint(&self) -> bool {
true
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

While you are adding support for Spark flags in Databricks, I believe you should also add supports_pipe_operator and parse_infix for DIV.

Comment thread src/dialect/databricks.rs
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DatabricksDialect;

impl Dialect for DatabricksDialect {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe there is some argument to be made that, since several of these properties need to be kept aligned between Spark and Databricks, it may be desirable to call directly Spark methods in these methods instead of duplicating the scalar value.

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.

2 participants