Skip to content

Conversation

ykicisk
Copy link
Contributor

@ykicisk ykicisk commented Jul 9, 2025

Brief summary of the change made

Added support for

Are there any other side effects of this change that we should be aware of?

No

Pull Request checklist

  • Please confirm you have completed any of the necessary steps below.

  • Included test cases to demonstrate any code changes, which may be one or more of the following:

    • .yml rule test cases in test/fixtures/rules/std_rule_cases.
    • .sql/.yml parser test cases in test/fixtures/dialects (note YML files can be auto generated with tox -e generate-fixture-yml).
    • Full autofix test cases in test/fixtures/linter/autofix.
    • Other.
  • Added appropriate documentation for the change.

  • Created GitHub issues for any relevant followup/future enhancements if appropriate.

Copy link
Contributor

github-actions bot commented Jul 9, 2025

Coverage Results ✅

Name    Stmts   Miss  Cover   Missing
-------------------------------------
TOTAL   19870      0   100%

253 files skipped due to complete coverage.

@ykicisk ykicisk marked this pull request as ready for review July 9, 2025 09:46
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Added comprehensive support for Trino dialect's ALTER TABLE statements and NOT NULL constraints in CREATE TABLE statements, with complete test coverage.

  • Extended src/sqlfluff/dialects/dialect_trino.py to implement ALTER TABLE operations (rename, add/drop columns, set properties)
  • Added new lexer and parser support for execute arrow ('=>') operator in dialect_trino.py
  • Created test/fixtures/dialects/trino/alter_table.sql with extensive test cases for all ALTER TABLE variations
  • Enhanced test/fixtures/dialects/trino/create_table.sql to include NOT NULL constraint testing
  • Added comprehensive test coverage in corresponding YAML files for all new syntax features

5 files reviewed, 5 comments
Edit PR Review Bot Settings | Greptile

Comment on lines +154 to +160
- column_definition:
- naked_identifier: shipmentstatus
- data_type:
keyword: varchar
- keyword: not
- keyword: 'null'
- comma: ','
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Inconsistent indentation in column definition compared to other similar blocks in this file. Other column definitions use double indentation.

Comment on lines +158 to +159
- keyword: not
- keyword: 'null'
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Keep NOT NULL case consistent with other keywords in file (uppercase).

Comment on lines 27 to 28
ALTER TABLE t1 SET PROPERTIES x = 'y';
ALTER TABLE t1 SET PROPERTIES foo = 123, bar = 456;
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Add test for setting property to DEFAULT value, which is a documented feature for reverting properties to default values

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have addressed it in these commits.
ec39758...992ab05

Comment on lines +906 to +918
OneOf(
Sequence(
"SET",
"DATA",
"TYPE",
Ref("DatatypeSegment"),
),
Sequence(
"DROP",
"NOT",
"NULL",
),
),
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: missing support for 'SET NOT NULL' in ALTER COLUMN

Suggested change
OneOf(
Sequence(
"SET",
"DATA",
"TYPE",
Ref("DatatypeSegment"),
),
Sequence(
"DROP",
"NOT",
"NULL",
),
),
OneOf(
Sequence(
"SET",
"DATA",
"TYPE",
Ref("DatatypeSegment"),
),
Sequence(
"SET",
"NOT",
"NULL"
),
Sequence(
"DROP",
"NOT",
"NULL",
),
),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trino's ALTER TABLE statement does not support the SET NOT NULL syntax.
https://trino.io/docs/current/sql/alter-table.html

Comment on lines +862 to +866
match_grammar = Sequence(
"ALTER",
"TABLE",
Ref("IfExistsGrammar", optional=True),
Ref("TableReferenceSegment"),
Copy link
Contributor

Choose a reason for hiding this comment

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

style: no support for 'ALTER TABLE ... COMMENT ON COLUMN' operation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trino's ALTER TABLE statement does not support the COMMENT ON COLUMN syntax.
https://trino.io/docs/current/sql/alter-table.html

"SET",
"DATA",
"TYPE",
Ref("DatatypeSegment"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to support datatypes with brackets like in ColumnDefinitionSegment?

Bracketed(Anything(), optional=True),  # For types like VARCHAR(100)

Copy link
Contributor Author

@ykicisk ykicisk Jul 10, 2025

Choose a reason for hiding this comment

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

@keraion
Thank you for your feedback!

DatatypeSegment already supports syntax like VARCHAR(100).

# String
Sequence(
OneOf("CHAR", "VARCHAR"),
Ref("BracketedArguments", optional=True),
),

I fixed ColumnDefinitionSegment and added the test.
df6bbc4

Copy link
Contributor

@keraion keraion left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@keraion keraion added this pull request to the merge queue Jul 10, 2025
Merged via the queue into sqlfluff:main with commit 07db73d Jul 10, 2025
28 checks passed
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