8000 fix(clickhouse): add support for DateTime64(precision, tz) and Tuples() by ogirardot · Pull Request #6060 · sqlfluff/sqlfluff · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(clickhouse): add support for DateTime64(precision, tz) and Tuples() #6060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 11, 2024

Conversation

ogirardot
Copy link
Contributor

Brief summary of the change made

The changes introduce support on the Clickhouse dialect for types and type casts related to DateTime64 and Tuple (structs in clickhouse), the following syntaxes were unparseable using sqlfluff 3.1.0 (and dbt-clickhouse 1.8.1, with sqlfluff-templater-dbt==3.1.0 as example :

SELECT (1, 'two', '2024-01-01')::Tuple(id Int64, name String, created_at Date32) as struct;
-- and 
SELECT '2024-01-01'::DateTime64(3, 'Europe/Paris') as datetime;

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

Nope

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:

    • .sql/.yml parser test cases in test/fixtures/dialects (note YML files can be auto generated with tox -e generate-fixture-yml).

Copy link
Contributor
github-actions bot commented Aug 11, 2024

Coverage Results ✅

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

228 files skipped due to complete coverage.

@coveralls
Copy link
coveralls commented Aug 11, 2024

Coverage Status

coverage: 99.985%. remained the same
when pulling 32640ee on ogirardot:og/datetime-and-tuples
into 2516b5d on sqlfluff:main.

Copy link
Member
@alanmcruickshank alanmcruickshank left a comment

Choose a reason for hiding this comment

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

Thanks for contributing this!

Changes look mostly good. Thanks for following the same pattern used in the bigquery dialect.

One thing which isn't critical, but would be nice is whether we can get DateTime64 to parse as a data_type_identifier rather than a keyword in the test cases 🤔 . That way they'll get handled appropriately by the capitalisation rules.

I think the best way to achieve that would be instead of just "DATETIME64", you use the slightly longer StringParser("DATETIME64", DatatypeIdentifierSegment). It's a big more verbose but I think it's more robust on how things get treated in the rules.

You've also got some linting issues in the CI suite, but they should be fairly easy to resolve.

@ogirardot
Copy link
Contributor Author

@alanmcruickshank it should be good to go, I fixed the last violations of the pre-commit. Thank you for your time and review

Copy link
Member
@alanmcruickshank alanmcruickshank 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 for your contribution, and especially for taking the time to make the edits.

@alanmcruickshank alanmcruickshank added this pull request to the merge queue Aug 11, 2024
Merged via the queue into sqlfluff:main with commit 898fe94 Aug 11, 2024
30 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.

3 participants
0