Fix assert_equal never comparing map values [databricks] #17285
All Vouch review confidence checks passed
Residual risk 0.27 = Change Risk (0.50) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 582 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.381
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #17285"
general
weight: 0.35
gerashegalov
Contributes to #17018.
Description
assert_equalinintegration_tests/src/main/python/asserts.pynever compared dict (map) values. The dict branch calledlist(cpu.items()).sort(key=_RowCmp), andlist.sort()returnsNone, so it comparedNonetoNoneand always passed. The fix is to usesorted(...). The sort cost is unchanged. The same bug was inudf_cudf_test.py(cpu_ret.sort() == gpu_ret.sort()), which is fixed here too.With the check actually running, a number of tests now fail. These are real CPU/GPU differences or test side problems that the broken assert was hiding. How each group is handled:
| Issue | Problem | Handling in this PR |
|---|---|---|
| #17281 |
map_zip_withreturns values attached to the wrong keys (mapZipis evaluated twice inGpuMapZipWith, andindices_ofin the JNI kernel usesidx % startinstead ofidx - start) |MapZipWithis now disabled by default with a documented reason (docs/compatibility.md). The tests enable it explicitly and arexfail. A new test checks the fallback. || #15240 (was #17282) |
from_jsontoMAP<STRING,STRING>keeps raw JSON text where the CPU normalizes it |xfailciting #15240. Intest_from_json_map_string_string, only the 12 input files that fail carryxfail(strict=True). The 7 that pass stay guarded. || #17283 | Spark's Hive SerDe writer collapses
MAP<DATE, …>keys (upstream Spark bug, the GPU result is correct) | No xfail. The date-keyed map generator now uses an int key with date values, so the rest of the write tests stay covered. || #17284 |
DESCRIBE HISTORYoperationMetricsbyte counts differ | Fixed here instead of xfailing:assert_delta_history_equalnormalizes both histories with the existing_fixup_*helpers. || (new) | Before Spark 4.0 the CPU keeps
0.0and-0.0as separate map keys (SPARK-47563) and cuDF merges them, sotest_map_concat,test_map_concat_with_litandtest_map_from_arraysfail on some seeds | No xfail. Float/Double map keys drop-0.0on Spark < 4.0 and keep NaN. The existing helpers moved fromarray_test.pytodata_gen.py. |Changes for DBR 17.3, from the failures reported in the PR comments:
normalized_add_actionsnow builds its physical-to-logical column map per commit frommetaData.schemaString. Before, it used only the final schema, which left version 0 column names unmapped.assert_delta_history_equaltakesignore_metrics, and the empty-input CTAS/RTAS test ignoresnumFiles. An empty GPU write can emit a zero-row Parquet file where the DBR CPU emits none.Testing
asserts_regression_test.py:- Equal maps with different insertion order pass.
- Unequal maps raise
AssertionError: different value, swapped values, missing entry, extra entry and different key.- Nested map values and NaN keys, plus a mismatch test for each.
- A NaN-row test for
assert_equal_with_local_sort.map_test.py,json_test.py,json_matrix_test.py,hive_parquet_write_test.py, the Delta tests (Delta 4.1.0) and the Iceberg tests (Iceberg 1.11.0).Validation gaps
normalized_add_actionschange and thenumFileshandling follow the failures reported in the DBR run on this PR. I did not run them on DBR. The[databricks]tag is on the title so the DBR suites run.udf_cudf_test.py) and the Scala unit tests were not run locally.Related PRs
assert_delta_history_equalchange. The helper code here is identical. #17297 also adds unit tests for the helper, which this PR does not.Checklists
Documentation
Testing
Performance
MapZipWithis now disabled by default, somap_zip_withqueries run on the CPU instead of returning wrong results on the GPU. No performance comparison is meaningful while the GPU output is wrong. Re enabling is tracked in #17281, and users can opt in withspark.rapids.sql.expression.MapZipWith=true. Everything else in this PR is test only.