-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Use "describe table" to get the columns in a relation on snowflake (#2260) #2324
Use "describe table" to get the columns in a relation on snowflake (#2260) #2324
Conversation
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.
One quick comment here - curious what you think about it
{% if (result | length) >= maximum %} | ||
{% set msg %} | ||
Too many columns in relation {{ relation }}! dbt can only get | ||
information about relations with fewer than {{ maximum }} columns. |
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 hope nobody ever sees this error message :p
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 actually don't know for sure that this is a limit, I just assumed it based on all the other commands. I'm comfortable saying that if someone has 10k columns in a table, we can revisit this then :)
@@ -108,3 +110,46 @@ def numeric_type(cls, dtype: str, precision: Any, scale: Any) -> str: | |||
|
|||
def __repr__(self) -> str: | |||
return "<Column {} ({})>".format(self.name, self.data_type) | |||
|
|||
@classmethod |
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.
While we're in here, can we override the string_size
on the SnowflakeColumn
class? I think right now, the base logic looks like:
def string_size(self) -> int:
if not self.is_string():
raise RuntimeException("Called string_size() on non-string field!")
if self.dtype == 'text' or self.char_size is None:
# char_size should never be None. Handle it reasonably just in case
return 256
else:
return int(self.char_size)
But on Snowflake, we want to map TEXT
, STRING
, or VARCHAR
(with no size specified) to VARCHAR(MAX)
, which is 16777216.
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.
LGTM :)
resolves #2260
Description
Use
describe table
to get the columns in a relation on snowflake. This requires doing some extra parsing to interpret varchars and numerics (with a regex...), but that's really all we get withdescribe table
.Checklist
CHANGELOG.md
and added information about my change to the "dbt next" section.