Repository navigation
Conversation
Snowflake requires a variable's value to match the type the view declares, and Snowflake ODBC driver 4.x binds a number as text, so a parameterized metric call failed. The declared type is now kept when the view is read, and the metric query and the access probe both write CAST(? AS <type>). A declared type that is not a plain type name is not spliced into SQL, and that variable keeps a bare placeholder. Closes #447
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #447
This PR makes R cast a Snowflake semantic view's variables to the type the view declares. Snowflake refuses a value of another type, and Snowflake ODBC driver 4.x binds a number as text, so a parameterized metric call failed.
Details (agent-written)
semantic_parameters_from_spec()now keeps a Snowflake variable's declared type. A new helper incatalog-snowflake.RwritesVARIABLES "MIN_TOTAL" => CAST(? AS NUMBER(10,2)), and both the metric query and the access probe use it. The type is put into SQL, so only a plain type name such asNUMBER(10,2)orTIMESTAMP_TZis kept. Any other declaration leaves its variable with a bare placeholder, as before.I cast to the declared type rather than to a fixed one:
CAST(? AS NUMBER)also passes Snowflake's check, but it rounds50.5to51.Testing: the full R suite passes, with new cases for the cast and for a declared type that is not a plain name. On live Snowflake, every R Snowflake live test passes with this stack, including the three semantic view tests. I ran it with driver 4.0.0 on macOS only. CI on Linux may bind numbers differently, but the cast is correct for either.
Kata: whhh.
R changes
A Snowflake semantic view variable is now bound with a cast to the type the view declares (
catalog-snowflake.R). A call such ascall_metrics(..., arguments = '{"MIN_TOTAL": 50}')against a view that declaresMIN_TOTAL NUMBER(10,2)used to fail with a type mismatch, and now returns the metric. Typed arguments for Snowflake gain an internalsql_typefield. Databricks metric views are unchanged. NEWS has a bullet.