-
Notifications
You must be signed in to change notification settings - Fork 179
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
first pass: unit test typing #839
Conversation
Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the dbt-snowflake contributing guide. |
|
||
from dbt.adapters.base.column import Column | ||
from dbt.exceptions import DbtRuntimeError | ||
|
||
|
||
@dataclass | ||
class SnowflakeColumn(Column): | ||
TYPE_LABELS: ClassVar[Dict[str, str]] = { | ||
"FIXED": "NUMERIC", |
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.
Note this means model contract errors will now say NUMERIC
instead of FIXED
— and they will say this for all fixed-precision numeric types, including integers, because INT
on Snowflake is just an alias for NUMERIC(38,0)
.
Compilation Error in model my_model (models/my_model.sql)
This model has an enforced contract that failed.
Please ensure the name, data_type, and number of columns in your contract match the columns in your model's definition.
| column_name | definition_type | contract_type | mismatch_reason |
| ----------- | --------------- | ------------- | ------------------ |
| ID | NUMERIC | TEXT | data type mismatch |
This is more helpful IMO, because numeric
is a real type that Snowflake will actually allow you to write in SQL!
Floating-point types will still appear as REAL
, and dbt will detect mismatch:
Compilation Error in model my_model (models/my_model.sql)
This model has an enforced contract that failed.
Please ensure the name, data_type, and number of columns in your contract match the columns in your model's definition.
| column_name | definition_type | contract_type | mismatch_reason |
| ----------- | --------------- | ------------- | ------------------ |
| ID | NUMERIC | REAL | data type mismatch |
|
||
from dbt.adapters.base.column import Column | ||
from dbt.exceptions import DbtRuntimeError | ||
|
||
|
||
@dataclass | ||
class SnowflakeColumn(Column): | ||
TYPE_LABELS: ClassVar[Dict[str, str]] = { |
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.
The parent/default Column.TYPE_LABELS
has STRING -> TEXT
. I haven't included it here because these are true aliases on Snowflake.
requires case-insensitivity changes in dbt-labs/dbt-core#9131