Commit b8ebc80
Fix: normalize rows_affected to handle string values from dbt-databricks (#915)
* Fix: normalize rows_affected to handle string values from dbt-databricks
When using dbt-databricks with view_update_via_alter enabled, skipped views
return rows_affected as a string '-1' instead of an integer. This causes
Spark's VALUES clause to fail with INVALID_INLINE_TABLE.INCOMPATIBLE_TYPES_IN_INLINE_TABLE
when building bulk INSERTs for dbt_run_results.
The fix adds a normalize_rows_affected macro that:
- Converts string '-1' to null (skipped operations have no meaningful row count)
- Converts other string numbers to integers (defensive handling)
- Passes through normal integers unchanged
Fixes: elementary-data/elementary#2089
Linear: CORE-267
Co-Authored-By: Yosef Arbiv <yosef.arbiv@gmail.com>
* Add unit test for normalize_rows_affected macro
Tests the following cases:
- None input returns None
- Integer inputs pass through unchanged (123, 0, -1)
- String '-1' returns None (skipped operations)
- Other string numbers are converted to integers ('123', '0', '456')
Co-Authored-By: Yosef Arbiv <yosef.arbiv@gmail.com>
* Fix test macro to not double-encode JSON results
The log_macro_results helper already applies tojson() to the result,
so the test macro should return the raw value instead of tojson(result).
Co-Authored-By: Yosef Arbiv <yosef.arbiv@gmail.com>
* Fix test to handle None return values from macro
When the macro returns None, log_macro_results doesn't log anything,
so run_operation returns an empty list. The test now handles this case
by checking if the result list is empty before parsing.
Co-Authored-By: Yosef Arbiv <yosef.arbiv@gmail.com>
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Yosef Arbiv <yosef.arbiv@gmail.com>1 parent 2396f71 commit b8ebc80
3 files changed
Lines changed: 54 additions & 1 deletion
File tree
- integration_tests
- dbt_project/macros
- tests/test_dbt_artifacts
- macros/edr/dbt_artifacts
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
40 | 54 | | |
41 | 55 | | |
42 | 56 | | |
43 | 57 | | |
| 58 | + | |
44 | 59 | | |
45 | 60 | | |
46 | 61 | | |
47 | 62 | | |
48 | 63 | | |
49 | 64 | | |
50 | 65 | | |
51 | | - | |
| 66 | + | |
52 | 67 | | |
53 | 68 | | |
54 | 69 | | |
| |||
0 commit comments