Skip to content
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

Improve datatypes: CHARACTER VARYING for ANSI, and Postgres and also TIMESTAMP AT TIME ZONE for Postgres #1378

Merged
merged 10 commits into from
Sep 13, 2021

Conversation

WittierDinosaur
Copy link
Contributor

@WittierDinosaur WittierDinosaur commented Sep 10, 2021

Brief summary of the change made

Added CHARACTER VARYING as parsable data types to ANSI
Added CHARACTER VARYING and TIMESTAMP AT TIME ZONE "MY_TIMEZONE" as parsable data types to Postgres

Fixes #1331
Fixes #733

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

No

Pull Request checklist

Tests added for both of the bugs' examples.

@tunetheweb
Copy link
Member

tunetheweb commented Sep 12, 2021

Added to ANSI, as I don't think having these available is breaking to other languages.

I'm not so sure about that decision to be honest. BigQuery, TeraData, and T-SQL already have their own definition of DataTypeSegment. Should we not just add one for Postgres unless there's a good reason to add this to ANSI?

@WittierDinosaur
Copy link
Contributor Author

Can we make a deal? Character Varying is an ANSI data type. TIMESTAMP AT TIME ZONE is dialect-specific. But, ANSI is also missing Data Types. For example, CHARACTER LARGE OBJECT. This PR fixes live issues. I agree that TIMESTAMP AT TIME ZONE should be Postgres-only. But I think the types logic needs an overhaul anyway, it's too generic right now. So can we merge this, then look at setting the types right across dialects?

@tunetheweb
Copy link
Member

Can we make a deal? Character Varying is an ANSI data type. TIMESTAMP AT TIME ZONE is dialect-specific. But, ANSI is also missing Data Types. For example, CHARACTER LARGE OBJECT. This PR fixes live issues. I agree that TIMESTAMP AT TIME ZONE should be Postgres-only. But I think the types logic needs an overhaul anyway, it's too generic right now. So can we merge this, then look at setting the types right across dialects?

What's your thinking here for not splitting ANSI and Postgres now? While I agree ANSI is not complete, that's not a reason to knowingly add an incorrect one to that, when we're going to have to split our Postgres at some point anyway. Especially when lots of other dialects already have their own implementations of this section. If it required a whole lot of reengineering I could maybe see your point but since it simply requires a copy and paste of the ANSI dialog to the Postgres dialect and then removing the "TIMESTAMP AT TIME ZONE" that your added from ANSI, then why not just do it in this PR?

@WittierDinosaur
Copy link
Contributor Author

Okay, fair point. Changed.

Copy link
Member

@tunetheweb tunetheweb 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 humouring me!

Just one small thing I spotted and then think we're good to merge.

src/sqlfluff/dialects/dialect_ansi.py Outdated Show resolved Hide resolved
@tunetheweb tunetheweb changed the title Postgres datatypes bugs Improve datatypes: CHARACTER VARYING for ANSI, and Postgres and also TIMESTAMP AT TIME ZONE for Postgres Sep 13, 2021
@tunetheweb tunetheweb merged commit 59743e2 into sqlfluff:main Sep 13, 2021
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.

Parsing support for postgres at time zone [Postgres] unparseable error on character varying type
2 participants