Does anyone have any insight on what the actual pr...
# announcements
n
Does anyone have any insight on what the actual prerequisites are to use target-snowflake?
d
n
I am using the meltano one @douwe_maan. I set up the DB in snowflake and used the owners credentials to connect from meltano, but it keeps erroring out. Relevant error meesages
Copy code
CRITICAL (snowflake.connector.errors.ProgrammingError) 002003 (02000): SQL compilation error:
CRITICAL Schema 'TEST."bingads"' does not exist or not authorized.
CRITICAL [SQL: GRANT USAGE ON SCHEMA "TEST"."bingads" TO ROLE MELTANO;]
CRITICAL (Background on this error at: <http://sqlalche.me/e/13/f405>)
meltano was set as the owner for the sake of testing just to avoid problems
d
@nevin_morgan Just a hunch: Does it work if you explicitly set the
schema
setting to an all-caps
BINGADS
? You can use the
SF_SCHEMA
env var if you like.
I have no idea if the capitalization should actually matter or not, but https://gitlab.com/meltano/target-snowflake/-/blob/master/target_snowflake/snowflake_loader.py#L145-149 suggests that
self.table.schema
should be in caps, even though the target never calls
upper
to make sure that's the case.
n
I haven't tried, but I can here in a little bit. I will probably fork that and force it to upper since I am pretty sure snowflake wants it to be uppercase
d
(As I'm sure is clear by now, I know Singer and Meltano pretty well, but Snowflake is also a mystery to me 😛)
n
My hope was to rely on the automatic schema naming so that I didn't need to modify env per pipeline
d
Yeah, makes sense. Updating the target to force that works for me, but we could also have Meltano apply the upper conversion using a new
value_processor: upper
setting property (we already have
value_processor: nest_object
, so adding "upper" or "upcase_string" or something to that effect wouldn't be too difficult)
Feel free to submit an MR to meltano/target-snowflake though, if we determine this is always the desired behavior 🙂
n
seems that this is the answer
Snowflake uses Standard (case-sensitive) SQL comparison semantics. Snowflake automatically converts unquoted, case-insensitive identifiers to uppercase internally, so an unquoted object name appears in upper case in the Information Schema views.
d
Interesting! So I'm guessing that https://gitlab.com/meltano/target-snowflake/-/blob/master/target_snowflake/snowflake_loader.py#L185 ends up passing
self.table.schema
unquoted, ignoring the lower case and actually creating an uppercase schema, while https://gitlab.com/meltano/target-snowflake/-/blob/master/target_snowflake/snowflake_loader.py#L394 quotes
self.table.schema
, expecting it to exist in the lowercase version
So we could either always uppercase
self.table.schema
, or make sure that it gets created exactly as provided, with quotes. The former will probably lead to fewer headaches, since
self.table.schema
is passed along to a few different methods that I'm not sure all respect the casing
Note that I haven't verified that https://gitlab.com/meltano/target-snowflake/-/blob/master/target_snowflake/snowflake_loader.py#L185 will actually create an uppercase schema even if a lowercase one was provided, but that does seem to match the behavior we're seeing
n
I definitely like upper casing the schema since it matches what happens if anything passes a non quoted string to snowflake. On the snowflake end it apparently is case insensitive and does a conversion regardless of what is sent to uppercase when an object name isn't a quoted string
I will have to see if snowflake support can confirm that for me just so that the known can be truly known
d