Skip to content

Commit

Permalink
Fix WITH [NO] DATA parsing in CTAS statement (#962)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgesittas authored Jan 17, 2023
1 parent d7fec3b commit e61d2d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 3 additions & 4 deletions sqlglot/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1613,13 +1613,12 @@ def _parse_table(
if alias:
this.set("alias", alias)

if self._match(TokenType.WITH):
if self._match_pair(TokenType.WITH, TokenType.L_PAREN):
this.set(
"hints",
self._parse_wrapped_csv(
lambda: self._parse_function() or self._parse_var(any_token=True)
),
self._parse_csv(lambda: self._parse_function() or self._parse_var(any_token=True)),
)
self._match_r_paren()

if not self.alias_post_tablesample:
table_sample = self._parse_table_sample()
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/identity.sql
Original file line number Diff line number Diff line change
Expand Up @@ -647,3 +647,5 @@ ALTER TABLE mydataset.mytable DROP COLUMN A, DROP COLUMN IF EXISTS B
ALTER TABLE mydataset.mytable ADD COLUMN A TEXT, ADD COLUMN IF NOT EXISTS B INT
SELECT div.a FROM test_table AS div
WITH view AS (SELECT 1 AS x) SELECT * FROM view
CREATE TABLE asd AS SELECT asd FROM asd WITH NO DATA
CREATE TABLE asd AS SELECT asd FROM asd WITH DATA

0 comments on commit e61d2d9

Please sign in to comment.