|
183 | 183 | column_name, |
184 | 184 | 'schema_change' as test_type, |
185 | 185 | change as test_sub_type, |
186 | | - case |
187 | | - when change = 'column_added' |
188 | | - then |
189 | | - {{ |
190 | | - dbt.concat( |
191 | | - ["'The column \"'", "column_name", "'\" was added'"] |
192 | | - ) |
193 | | - }} |
194 | | - when change = 'column_removed' |
195 | | - then |
196 | | - {{ |
197 | | - dbt.concat( |
198 | | - ["'The column \"'", "column_name", "'\" was removed'"] |
199 | | - ) |
200 | | - }} |
201 | | - when change = 'type_changed' |
202 | | - then |
203 | | - {{ |
204 | | - dbt.concat( |
205 | | - [ |
206 | | - "'The type of \"'", |
207 | | - "column_name", |
208 | | - "'\" was changed from '", |
209 | | - "pre_data_type", |
210 | | - "' to '", |
211 | | - "data_type", |
212 | | - ] |
213 | | - ) |
214 | | - }} |
215 | | - else null |
216 | | - end as test_results_description |
| 186 | + {{ elementary.schema_change_description_column() }} |
217 | 187 | from all_column_changes {{ elementary.schema_changes_query_group_by() }} |
218 | 188 |
|
219 | 189 | ) |
|
272 | 242 | group by full_table_name, change, column_name, data_type, pre_data_type, detected_at |
273 | 243 | {% endmacro %} |
274 | 244 |
|
| 245 | +{% macro schema_change_description_column() %} |
| 246 | + {{ return(adapter.dispatch("schema_change_description_column", "elementary")()) }} |
| 247 | +{% endmacro %} |
| 248 | + |
| 249 | +{% macro default__schema_change_description_column() %} |
| 250 | + case |
| 251 | + when change = 'column_added' |
| 252 | + then {{ dbt.concat(["'The column \"'", "column_name", "'\" was added'"]) }} |
| 253 | + when change = 'column_removed' |
| 254 | + then {{ dbt.concat(["'The column \"'", "column_name", "'\" was removed'"]) }} |
| 255 | + when change = 'type_changed' |
| 256 | + then |
| 257 | + {{ |
| 258 | + dbt.concat( |
| 259 | + [ |
| 260 | + "'The type of \"'", |
| 261 | + "column_name", |
| 262 | + "'\" was changed from '", |
| 263 | + "pre_data_type", |
| 264 | + "' to '", |
| 265 | + "data_type", |
| 266 | + ] |
| 267 | + ) |
| 268 | + }} |
| 269 | + else null |
| 270 | + end as test_results_description |
| 271 | +{% endmacro %} |
| 272 | + |
| 273 | +{% macro fabric__schema_change_description_column() %} |
| 274 | + {#- Fabric does not support nvarchar; CONCAT() returns nvarchar so we cast to varchar. -#} |
| 275 | + cast( |
| 276 | + case |
| 277 | + when change = 'column_added' |
| 278 | + then {{ dbt.concat(["'The column \"'", "column_name", "'\" was added'"]) }} |
| 279 | + when change = 'column_removed' |
| 280 | + then |
| 281 | + {{ dbt.concat(["'The column \"'", "column_name", "'\" was removed'"]) }} |
| 282 | + when change = 'type_changed' |
| 283 | + then |
| 284 | + {{ |
| 285 | + dbt.concat( |
| 286 | + [ |
| 287 | + "'The type of \"'", |
| 288 | + "column_name", |
| 289 | + "'\" was changed from '", |
| 290 | + "pre_data_type", |
| 291 | + "' to '", |
| 292 | + "data_type", |
| 293 | + ] |
| 294 | + ) |
| 295 | + }} |
| 296 | + else null |
| 297 | + end as varchar(4000) |
| 298 | + ) as test_results_description |
| 299 | +{% endmacro %} |
| 300 | + |
275 | 301 | {% macro fabric__get_column_changes_from_baseline_cur( |
276 | 302 | model_relation, full_table_name, model_baseline_relation |
277 | 303 | ) %} |
|
0 commit comments