Conversation
a73feca to
921ee2a
Compare
1fcb668 to
7384e43
Compare
|
|
||
| !!! warning "Ignore is Dangerous" | ||
|
|
||
| `ignore` is dangerous since it can result in error or data loss. It likely should never be used but could be useful as an "escape-hatch" or a way to workaround unexpected behavior. |
There was a problem hiding this comment.
Why would it result in data loss?
There was a problem hiding this comment.
Also how can it result in error?
There was a problem hiding this comment.
Also how can it result in error?
If you made a data type change to a new type that isn't coerceable. The next time it runs it would error trying to insert the rows (since the underlying table wasn't actually changed).
Why would it result in data loss?
Not certain yet. Putting this warning for now as we do more testing with this fully implemented in the dbt adapter. After a bit if we don't identify any issues I can remove this part of the warning. For now though I would rather overly caution native users about this feature.
I'm somewhat confused. Does changing the position result in a destructive change? |
No it doesn't. The SchemaDiffer though requires that it can properly track the future state of the changes it is generating in order to properly understand where columns should be inserted. So if it thought columns would be dropped when they would actually still exist then it might put columns in expected positions as a result. |
af20b9b to
d1d6be9
Compare
| snowpark = optional_import("snowflake.snowpark") | ||
|
|
||
| Query = t.Union[exp.Query, exp.DerivedTable] | ||
| Query = exp.Query |
There was a problem hiding this comment.
Discussed internally and we don't see a reason why exp.DerivedTable was expected before and that code is from version 0.0.2 so assuming it is no longer needed.
404ea84 to
c0cef4e
Compare
a9c8d06 to
fc7a0c7
Compare
9d7f1fb to
0885a31
Compare
155fc2b to
912348b
Compare
c61f368 to
322249a
Compare
d118afb to
990c979
Compare
990c979 to
8b5c788
Compare
BREAKING:
columns_to_typeshas been renamed totarget_columns_to_typesfor engine adapter methods.This PR adds support for "ignoring" a destructive change using the
on_destructive_changeproperty. As documentation says, this property should not be used in most cases and is really just being added for dbt support. It could be useful though for an "escape-hatch" situation.The concept of ignoring a destructive change is pushed down to the SchemaDiffer class level because the SchemaDiffer needs to be aware of this property is being used due to positional changes. If the engine supports positional changes and the SchemaDiffer wasn't aware then it could generate alter commands that involve changing columns assuming a column order that wouldn't really happen.
Prior to this PR, the engine adapter class assumed that the Query or DataFrame had the same columns as
columns_to_types.columns_to_typeshas been renamed totarget_columns_to_typesand now represents the target table columns and can now drift out of sync of the "source" query or DataFrame. To account for this, engine adapter methods which take aQueryOrDFnow also take asource_columnswhich tells the adapter what columns are in that source. If needed, it will pad out the columns in the source to match the target.Note: I am intentionally not changing dbt adapter implementation since I plan on updating it once
on_additive_changesupport is added in follow up PR. That will isolate the breaking changes related toon_schema_changesupport to a single PR and it is just breaking for dbt adapter.