-
Notifications
You must be signed in to change notification settings - Fork 510
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
Handle schema pattern on BQ #275
Conversation
where table_schema = '{{schema_pattern}}' | ||
and lower(table_name) like lower ('{{table_pattern}}') | ||
and lower(table_name) not like lower ('{{exclude}}') | ||
{% if '%' in schema_pattern %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, _
is a wildcard pattern (docs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that we actually introduced a slight regression by switching to using like
operators instead of =
operators
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I follow how this is a regression?
Question is, should we amend that line to be
{% if '%' in schema_pattern or '_' in schema_pattern %}
knowing we're going to get a lot more false positives...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I follow how this is a regression?
Let's say we have schemas named a_c
and abc
.
I think previously for get_relations_by_prefix
we used a strict =
for the schema name.
where schema_name = 'a_c'
This would return only a_c
.
Now, we pass it to a like
operator (i.e. here and here)
where schema_name like 'a_c'
This would return both a_c
and abc
.
It's a teeny tiny regression for anyone that uses get_relations_by_prefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see your point. To match only a_c
, the user should pass the pattern as a\\_c
. I still think it's okay to ship this in a patch release, maybe link to the BQ doc in the readme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think let's just ship this as-is, and if someone notices the regression we can fix it heh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really cool! Updated the integration test to (a) include an input table from a different schema, and (b) actually check for equality with an expected result. Smooth sailing on all databases, including BQ.
Just left one comment/question on your comment/question
where table_schema = '{{schema_pattern}}' | ||
and lower(table_name) like lower ('{{table_pattern}}') | ||
and lower(table_name) not like lower ('{{exclude}}') | ||
{% if '%' in schema_pattern %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I follow how this is a regression?
Question is, should we amend that line to be
{% if '%' in schema_pattern or '_' in schema_pattern %}
knowing we're going to get a lot more false positives...
Just ran into this :) For context, in our Blue/Green deployment pipeline, the schema changes from Blue to Green, so we'd like to use |
FYI, we are currently using
|
This is a:
master
)Description & motivation
We weren't handling the
schema_pattern
arg correctly. And it turns out that on BQ it's kind of annoying to handle it the right way. I think I got it though.Checklist
Local testing
I added this:
Raw:
analysis/foo.sql
Compiled:
LGTM :)
To discuss:
return
though