fix: View Creation fails with with reserved words in project name #22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
tl;dr
Once a reserved word, such as
new
, exists as part of a view creation step (e.g., in the project or table name), the BQ query fails.column_name_transforms.quote
does not work to mitigate this (only quotes field names).You can try this in the BQ consoled:
Steps to reproduce
Failure Scenarios
Denormalized, Quoted
The following statement was meant to achieve the creation of a regular, flat table. That failed with a different error, but I create a separate ticket for that.
Results in
Caused by the generated statement:
The word "new" only shows up in the project name as prefix, as outlined in the statement above, but causes the
CTAS
to fail. This is a legal project name, mind you.Default Settings
Works, but neither denormalizes, nor creates a view, making this data hard to use.
Suggested Fix: View Creation
Since it's legal BQ SQL to escape the entire table identifier, we could do that in the SQL strings.
This PR makes this a function of the
BigQueryTable
model, which is cleaner, IMO.name
or__str__
should not return a quoted string.Caveats:
Array cannot have a null element; error in writing field topics
error, but that could not be caused by this PR. That should probably be fixed, though. Probably also a separate ticket.All UTs and ITs pass, though.
Re-Test