-
Notifications
You must be signed in to change notification settings - Fork 4
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
Escaping identifieres makes them different #1
Comments
On our end, we handle this by passing the table names through a "bigquery_normalize_identifier(input, default_project_id)" function in our consuming application in Python. Background on how BigQuery handles unqualified table namesThe normalisation function receives two arguments, the identifier and default BigQuery project id the query should be executed in. BigQuery supports queries against tables identified only by their dataset + table name. e.g. A fully qualified table identifier can be written like so, encased in two backtick ( AlphaSQL could handle table name normalisationI can imagine AlphaSQL could normalise all identifiers it finds in a given set of queries. Given a query -- samples/issue-1/foo.sql
create or replace table core.foo as
select 'foo' as col1 And a query -- samples/issue-1/assert_foo.sql
select count(1) > 0
from `project-123.core.foo`
where col1 = 'foo' Now AlphaSQL could support a command-line argument to "qualify" all identifiers it encounters:
# Imaginary example
$ alphadag --with_tables --default_project_id=project-123 --qualify_identifiers samples/issue-1/ Currently AlphaSQL outputs the following information: # At the time of writing, AlphaSQL does not yet support these command line flags
$ alphadag --with_tables samples/issue-1/
Reading paths passed as a command line arguments...
Only files that end with .sql or .bq are analyzed.
Reading "samples/issue-1/assert_foo.sql"
Reading "samples/issue-1/foo.sql"
digraph G {
0 [label="samples/issue-1/assert_foo.sql", shape="", type=query];
1 [label="samples/issue-1/foo.sql", shape="", type=query];
2 [label="core.foo", shape=box, type=table];
3 [label="project-123.core.foo", shape=box, type=table];
1->2 ;
3->0 ;
}
EXTERNAL REQUIRED TABLES:
project-123.core.foo But it could (given the imaginary options) output the following normalised information. Note the labels on the digraph output. $ alphadag --with_tables --default_project_id=project-123 --qualify_identifiers samples/issue-1/
Reading paths passed as a command line arguments...
Only files that end with .sql or .bq are analyzed.
Reading "samples/issue-1/assert_foo.sql"
Reading "samples/issue-1/foo.sql"
digraph G {
0 [label="samples/issue-1/assert_foo.sql", shape="", type=query];
1 [label="samples/issue-1/foo.sql", shape="", type=query];
2 [label="`project-123.core.foo`", shape=box, type=table];
1->2 ;
2->0 ;
}
EXTERNAL REQUIRED TABLES: |
@lukas-at-harren I think that this issue is not an actual problem because Also, project_id is a dynamic property and making it an option seems complex for me. Could this issue be closed? |
Found that making |
Currently CREATE resources like I found that this is because nested catalog is not initialized. Instead, current implementation simply add resources with identifier vectors and this leads to errors We should improve the way to call For now, workaround is simply escaping like |
`dataset.table`
anddataset.table
are recognized as different identifieres.Unifying style in queries prevent this problem for a while.
The text was updated successfully, but these errors were encountered: