-
Notifications
You must be signed in to change notification settings - Fork 213
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
Snowflake engine does not support fulle range of characters in role/warehouse identifiers #685
Comments
Would you try the change in #688 please? Thank you! |
Hi, |
Oh. Bah. The docker project Only knows how to build released versions. Maybe we should look into changing that. Easiest might be to make a new Dockerfile, build --- a/lib/perl5/App/Sqitch/Engine/snowflake.pm
+++ b/lib/perl5/App/Sqitch/Engine/snowflake.pm
@@ -192,8 +192,6 @@ has dbh => (
my $self = shift;
$self->use_driver;
my $uri = $self->uri;
- my $wh = $self->warehouse;
- my $role = $self->role;
DBI->connect($uri->dbi_dsn, $self->username, $self->password, {
PrintError => 0,
RaiseError => 0,
@@ -210,11 +208,13 @@ has dbh => (
connected => sub {
my $dbh = shift;
try {
+ my $wh = $dbh->quote_identifier($self->warehouse);
+ my $role = $self->role;
$dbh->do($_) for (
- ($role ? ("USE ROLE $role") : ()),
+ ($role ? ("USE ROLE " . $dbh->quote_identifier($role)) : ()),
"ALTER WAREHOUSE $wh RESUME IF SUSPENDED",
"USE WAREHOUSE $wh",
- 'USE SCHEMA ' . $self->registry,
+ 'USE SCHEMA ' . $dbh->quote_identifier($self->registry),
'ALTER SESSION SET TIMESTAMP_TYPE_MAPPING=TIMESTAMP_LTZ',
"ALTER SESSION SET TIMESTAMP_OUTPUT_FORMAT='YYYY-MM-DD HH24:MI:SS'",
"ALTER SESSION SET TIMEZONE='UTC'",
@@ -224,7 +224,9 @@ has dbh => (
return;
},
disconnect => sub {
- shift->do("ALTER WAREHOUSE $wh SUSPEND");
+ my $dbh = shift;
+ my $wh = $dbh->quote_identifier($self->warehouse);
+ $dbh->do("ALTER WAREHOUSE $wh SUSPEND");
return;
},
}, |
This change seems to have had some unintended consequences. My automated deploys started failing on 8/2 and no code changes were made. I finally had time to dig into the issue today and noticed the difference in "USE SHCEMA" statements below. The first query, which was successful, was ran using sqitch 1.3.1. A client running 1.4 tried to deploy the same exact change and ran the improperly quoted statement in the second query. Pinning 1.3.1 resolved the issue for me.
|
Bloody hell, you can reference a schema in a different database??? |
@marc-marketparts Were you able to make it work by quoting the role and warehouse identifiers yourself? I'm beginning to think the Sqitch should do no quoting itself. :-( |
@theory What I have tried is:
The good news is that I have just gave it another try with a new idea and it works ! So it is a matter of documentation and this dev can be reverted. |
Ah yes, I didn't realize you were specifying it in the URI, which yes, must be percent-escaped. I will get this reverted and some docs added shortly. |
Added in v1.4.0. Turns out Snowflake allows a warehouse to be specified in a different database, in which case dots are valid in the name and should not be quoted! So users must properly quote when necessary, but added notes to `sqitchtutorial-snowflake.pod` on the need to use URI escapes for special characters. Resolves #685 (again/for real).
Okay have a look at #780. Might want to try using the environment variables, too! :-) |
Added in v1.4.0. Turns out Snowflake allows a warehouse to be specified in a different database, in which case dots are valid in the name and should not be quoted! So users must properly quote when necessary, but added notes to `sqitchtutorial-snowflake.pod` on the need to use URI escapes for special characters. Resolves #685 (again/for real).
Added in v1.4.0. Turns out Snowflake allows a warehouse to be specified in a different database, in which case dots are valid in the name and should not be quoted! So users must properly quote when necessary, but added notes to `sqitchtutorial-snowflake.pod` on the need to use URI escapes for special characters. Resolves #685 (again/for real).
If you use special characters like dot "." in either a role or a warehouse name, SQITCH will fail executing USE ROLE <role_name>, or USE WAREHOUSE <warehouse_name>.
As stated on Snowflake docs, identifiers can include a wide range of characters in object identifiers if they are quoted.
So far, the Sqitch snowflake engine supports unquoted identifiers only.
sqitch/lib/App/Sqitch/Engine/snowflake.pm
Lines 214 to 217 in 8f72ee6
The solution could be :
The text was updated successfully, but these errors were encountered: