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

Support the ARRAY type of Snowflake #699

Merged
merged 7 commits into from Nov 4, 2022

Conversation

yuval-illumex
Copy link
Contributor

@yuval-illumex yuval-illumex commented Nov 2, 2022

According snowflake documentation, There is an ARRAY type.
Behind the scenes it contains the VARIANT Data type, but the syntax is different. Snowflake don't support VARIANT[].
The query that I want to support is: SELECT CAST (a as array)
I started with creating a new data type called SnowflakeArray, But I think it's better to use the existing ARRAY data type (which created for the HIVE dialect)

@coveralls
Copy link

coveralls commented Nov 2, 2022

Pull Request Test Coverage Report for Build 3389576674

  • 27 of 27 (100.0%) changed or added relevant lines in 5 files are covered.
  • 234 unchanged lines in 4 files lost coverage.
  • Overall coverage increased (+0.01%) to 85.997%

Files with Coverage Reduction New Missed Lines %
src/lib.rs 2 10.0%
src/parser.rs 10 83.77%
tests/sqlparser_postgres.rs 23 97.81%
src/ast/mod.rs 199 77.07%
Totals Coverage Status
Change from base Build 3379170887: 0.01%
Covered Lines: 11048
Relevant Lines: 12847

💛 - Coveralls

Copy link
Collaborator

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution @yuval-illumex

src/parser.rs Outdated
Comment on lines 3676 to 3677
Ok(DataType::Array(Box::new(DataType::Custom(
ObjectName(vec!["VARAINT".into()]),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would prefer if this didn't add VARAINT into the parse tree when it wasn't in the original syntax. Can we model this like DataType::Array(None) perhaps?

@yuval-illumex
Copy link
Contributor Author

@alamb I change the data type to be Array(Option<Box<DataType>>) to accept None.
I don't think it breaks anything but waiting to your feedback :) (I'm new to Rust).

Thank you!

@yuval-illumex yuval-illumex changed the title Support the ARRAY type of Snowlfkae Support the ARRAY type of Snowflake Nov 3, 2022
Copy link
Collaborator

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Looks good to me -- thanks @yuval-illumex

@alamb alamb merged commit 0f7e144 into sqlparser-rs:main Nov 4, 2022
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.

None yet

3 participants