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

Add support for mixed BigQuery table name quoting #971

Merged
merged 1 commit into from
Oct 2, 2023

Conversation

iffyio
Copy link
Contributor

@iffyio iffyio commented Sep 20, 2023

As described in the gh issue, BigQuery accepts arbitrary quoting identifiers within table names - such that e.g: 'a.b.c' == 'a'.'b'.'c' == 'a.b'.'c' are all equivalent.

This adds support for such syntax

Fixes #889

Copy link
Contributor

@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 @iffyio

.flat_map(|ident| {
ident
.value
.split('.')
Copy link
Contributor

Choose a reason for hiding this comment

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

does BigQuery support any way to escape . (like 'foo\.bar' I wonder 🤔 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BigQuery didn't support escaping dots in identifiers either as far as I could tell and tested

@@ -84,9 +86,16 @@ fn parse_raw_literal() {

#[test]
fn parse_table_identifiers() {
fn test_table_ident(ident: &str, expected: Vec<Ident>) {
fn test_table_ident(ident: &str, canonical: Option<&str>, expected: Vec<Ident>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you please document what canonical represents in this context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added!

@alamb
Copy link
Contributor

alamb commented Sep 20, 2023

I wonder if you could respond to @MartinNowak 's comment #889 (comment) as well? Aka does this change really need to be in sqlparser-rs?

@iffyio
Copy link
Contributor Author

iffyio commented Sep 21, 2023

I wonder if you could respond to @MartinNowak 's comment #889 (comment) as well? Aka does this change really need to be in sqlparser-rs?

I'm not entirely sure I follow, the changes made in this MR were based off my understanding of what was being proposed in that comment, unless I misunderstood - maybe @MartinNowak can clarify otherwise

It wouldn't seem reasonable to do this outside the parser - without it, all users of the BigQuery dialect essentially get back wrong object names from the parser in such cases and will need to know to check all identifiers they get back and fix it up with code similar to the MR - effectively re-parsing the object name themself.

As described in the gh issue, BigQuery accepts arbitrary
quoting identifiers within table names - such that e.g:
`'a.b.c'` == `'a'.'b'.'c'` == `'a.b'.'c'` are all equivalent.

This adds support for such syntax

Fixes apache#889
@iffyio iffyio force-pushed the bq-quoted-identifiers branch from 3ff9d91 to 1084ff5 Compare September 21, 2023 06:31
Copy link
Contributor

@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 @iffyio

@alamb alamb merged commit 993769e into apache:main Oct 2, 2023
@iffyio
Copy link
Contributor Author

iffyio commented Oct 2, 2023

Thanks! :)

@iffyio iffyio deleted the bq-quoted-identifiers branch October 2, 2023 14:50
@yuval-illumex
Copy link
Contributor

@iffyio @alamb Thank you!!!

lustefaniak pushed a commit to getsynq/sqlparser-rs that referenced this pull request Nov 5, 2023
Co-authored-by: ifeanyi <[email protected]>
# Conflicts:
#	tests/sqlparser_bigquery.rs
serprex pushed a commit to serprex/sqlparser-rs that referenced this pull request Nov 6, 2023
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.

BigQuery ignores identifiers in FROM clause
3 participants