Skip to content

Parsing: Redshift dialect do not recognize comma absence in CREATE TABLE #6424

@alexey62soft

Description

@alexey62soft

Search before asking

  • I searched the issues and found no similar issues.

What Happened

The SQLFluff a gap in the parsing command which allows us to miss the issue in the following script (comma missed):

CREATE TABLE IF NOT EXISTS table1
(
id VARCHAR(50),
value1 VARCHAR(50) NULL
value2 VARCHAR(50) NULL
);

Expected Behaviour

We expect to see parsing errors like this:

L: 1 | P: 1 | PRS | Line 3, Position 1: Found unparsable section: 'CREATE TABLE IF NOT
| EXISTS table1...'

Observed Behaviour

Parsing goes fine:

[L: 1, P: 1] |file:
[L: 1, P: 1] | statement:
[L: 1, P: 1] | create_table_statement:
[L: 1, P: 1] | keyword: 'CREATE'
[L: 1, P: 7] | whitespace: ' '
[L: 1, P: 8] | keyword: 'TABLE'
[L: 1, P: 13] | whitespace: ' '
[L: 1, P: 14] | keyword: 'IF'
[L: 1, P: 16] | whitespace: ' '
[L: 1, P: 17] | keyword: 'NOT'
[L: 1, P: 20] | whitespace: ' '
[L: 1, P: 21] | keyword: 'EXISTS'
[L: 1, P: 27] | whitespace: ' '
[L: 1, P: 28] | table_reference:
[L: 1, P: 28] | naked_identifier: 'table1'
[L: 1, P: 34] | newline: '\n'
[L: 2, P: 1] | bracketed:
[L: 2, P: 1] | start_bracket: '('
[L: 2, P: 2] | [META] indent:
[L: 2, P: 2] | newline: '\n'
[L: 3, P: 1] | whitespace: ' '
[L: 3, P: 5] | column_reference:
[L: 3, P: 5] | naked_identifier: 'id'
[L: 3, P: 7] | whitespace: ' '
[L: 3, P: 8] | data_type:
[L: 3, P: 8] | keyword: 'VARCHAR'
[L: 3, P: 15] | bracketed_arguments:
[L: 3, P: 15] | bracketed:
[L: 3, P: 15] | start_bracket: '('
[L: 3, P: 16] | [META] indent:
[L: 3, P: 16] | numeric_literal: '50'
[L: 3, P: 18] | [META] dedent:
[L: 3, P: 18] | end_bracket: ')'
[L: 3, P: 19] | comma: ','
[L: 3, P: 20] | newline: '\n'
[L: 4, P: 1] | whitespace: ' '
[L: 4, P: 5] | column_reference:
[L: 4, P: 5] | naked_identifier: 'value1'
[L: 4, P: 11] | whitespace: ' '
[L: 4, P: 12] | data_type:
[L: 4, P: 12] | keyword: 'VARCHAR'
[L: 4, P: 19] | bracketed_arguments:
[L: 4, P: 19] | bracketed:
[L: 4, P: 19] | start_bracket: '('
[L: 4, P: 20] | [META] indent:
[L: 4, P: 20] | numeric_literal: '50'
[L: 4, P: 22] | [META] dedent:
[L: 4, P: 22] | end_bracket: ')'
[L: 4, P: 23] | whitespace: ' '
[L: 4, P: 24] | column_constraint_segment:
[L: 4, P: 24] | keyword: 'NULL'
[L: 4, P: 28] | newline: '\n'
[L: 5, P: 1] | whitespace: ' '
[L: 5, P: 5] | column_reference:
[L: 5, P: 5] | naked_identifier: 'value2'
[L: 5, P: 11] | whitespace: ' '
[L: 5, P: 12] | data_type:
[L: 5, P: 12] | keyword: 'VARCHAR'
[L: 5, P: 19] | bracketed_arguments:
[L: 5, P: 19] | bracketed:
[L: 5, P: 19] | start_bracket: '('
[L: 5, P: 20] | [META] indent:
[L: 5, P: 20] | numeric_literal: '50'
[L: 5, P: 22] | [META] dedent:
[L: 5, P: 22] | end_bracket: ')'
[L: 5, P: 23] | whitespace: ' '
[L: 5, P: 24] | column_constraint_segment:
[L: 5, P: 24] | keyword: 'NULL'
[L: 5, P: 28] | newline: '\n'
[L: 6, P: 1] | [META] dedent:
[L: 6, P: 1] | end_bracket: ')'
[L: 6, P: 2] | statement_terminator: ';'
[L: 6, P: 3] | [META] end_of_file:

How to reproduce

Run the parse command for the script above:

sqlfluff parse --dialect redshift --format human ./issue-test.sql

Dialect

redshift

Version

3.2.5

Configuration

No additional configuration

Are you willing to work on and submit a PR to address the issue?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingredshiftIssues relating to Amazon Redshift dialect

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions