Skip to content

fix: accept optional colon in Spark STRUCT field specs - #3

Draft
cnbei wants to merge 1 commit into
masterfrom
cursor/spark-struct-colon-c6b6
Draft

fix: accept optional colon in Spark STRUCT field specs#3
cnbei wants to merge 1 commit into
masterfrom
cursor/spark-struct-colon-c6b6

Conversation

@cnbei

@cnbei cnbei commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Fixes sql-formatter-org#900

Spark SHOW CREATE TABLE emits STRUCT<field: type> (colon optional). The spark tokenizer had no : operator, so struct <c: bigint> failed with Parse error: Unexpected ": bigint> ".

Recognize : in the spark dialect and combine ARRAY<T> / MAP<K, V> / STRUCT<field: T> type tokens (same approach as BigQuery's parametric STRUCT, plus Spark's optional colon and MAP).

Tests

pnpm exec jest test/spark.test.ts — 278 passed.

Open in Web Open in Cursor 

Spark SHOW CREATE TABLE emits STRUCT<field: type> with an optional
colon. Treat ':' as a spark operator and combine ARRAY/MAP/STRUCT
angle-bracket types so the dialect can parse and format that DDL.

Fixes sql-formatter-org#900

Co-authored-by: cnbei <baymy@foxmail.com>
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.

spark ddl with struct data type error

2 participants