Repository navigation
test(partition-mapping): cover Hive/Impala mirrored SQL, cache outage and migration - #46319
Conversation
… and migration - Golden mirrored-predicate SQL on Hive and Impala for hourly and daily epoch-key recipes across =, IN, >, >=, <, <= and the time range: unquoted integer keys, strict bounds widened, the NULL-partition escape, no leaked :value placeholder, and SQL the engine's parser reads. Only the warehouse probe is faked. - A cache outage fails open: charts keep their rows and their pruning, every chart re-probes, the mirror verdict reads as unknown, and each lost cache write logs a warning. - Migration a7f3c2e91d84 adds the four partition mapping columns to the dataset tables and their version tables, defaults existing columns to not monotonic, drops them on downgrade, and is safe to re-run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replace the golden-string Hive/Impala mirror test and its separate parse test with one test that reads the mirror from the engine's sqlglot tree: the bounds on the partition key are numeric literals equal to the expected epoch keys, strict bounds are widened, IN maps element-wise, the predicate is ORed with `key IS NULL` and ANDed onto the chart's own filter, and no `:value` placeholder remains. Identifier quoting and redundant parentheses no longer affect the outcome. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #46319 +/- ##
==========================================
- Coverage 85.66% 85.66% -0.01%
==========================================
Files 3111 3108 -3
Lines 214938 214745 -193
Branches 50908 50793 -115
==========================================
- Hits 184136 183953 -183
+ Misses 27381 27375 -6
+ Partials 3421 3417 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rusackas
left a comment
There was a problem hiding this comment.
Thanks @drivaspreset, nice set of gap-fills, and the mutation table in the description is a great touch. LGTM!
On your question about read vs. write failures: I think it's fine as is. A failed read just falls through to a fresh probe and the chart still works, so warning on every read while the cache is down would mostly be noise. Happy to revisit if anyone feels strongly.
Re-ran CI too, since the last run tripped over a GitHub API rate limit.
* origin/master: (393 commits) fix(a11y): name the semantic view description input (apache#46458) docs(semantic): explain datasource list modification eligibility (apache#46462) docs(semantic-layer): document NULL-preserving exclusion filters (apache#46447) fix(uploads): skip folder and system entries in columnar ZIP uploads (apache#45617) fix(i18n-es): promote 47 of the zero-context backfill entries (apache#45847) fix(mcp): return structured ChartError on SQLAlchemyError in get_chart_sql (apache#44351) fix(datasets): follow semantic view modification permissions (apache#46448) fix(docker): account for container memory limits in frontend-mem-nag.sh (apache#46373) fix(reports): carry the report's native filters in the email and Slack link (apache#46062) fix(explore): apply the dataset timezone to grained temporal filter values (apache#46175) fix(i18n): enforce the do-not-translate registry across the catalogs (apache#45974) chore(logging): log unparseable virtual dataset SQL at debug in the RLS lookup (apache#46139) fix(i18n): split parameter-suggestion plural into two messages (apache#46049) test(partition-mapping): cover Hive/Impala mirrored SQL, cache outage and migration (apache#46319) perf(dashboard): look up the dashboard once per filter_state read (apache#46314) fix(i18n): load the dayjs locale for every language with a catalog (apache#45982) test(semantic-layer): make date export parametrization deterministic (apache#46449) fix(oauth2): idempotent OAuth2 completion and resilient listener (apache#40292) fix(explore): prevent full table scan when SQL expression is used as x-axis (apache#41339) feat(mcp): radar chart type plugin (apache#43571) ... # Conflicts: # .github/workflows/docker.yml # .github/workflows/superset-frontend.yml
SUMMARY
Test-only change that closes three unit-test gaps in Partition Filter Mapping. No production code changes.
1. Hive/Impala-specific mirrored SQL (
tests/unit_tests/models/partition_mirroring_test.py)test_hive_family_mirrors_epoch_buckets_as_numeric_keys_or_nullruns 28 cases: Hive and Impala × hourly (3600) and daily (86400) epoch-key recipes ×==,IN,>,>=,<,<=and the time range.partition_mapping._probe, the single call that sends the transform to the warehouse. The chart SQL is compiled byget_query_strin each engine's own dialect.superset.sql.parse.SQLStatementbuilds for that engine, not from SQL text. It checks that:<becomes<=,>becomes>=);INmaps element-wise;key IS NULLand ANDed onto the chart's own filter;:valueplaceholder remains.2. Cache outage fails open (
tests/unit_tests/connectors/sqla/partition_verdict_identity_test.py)A
MagicMock(spec=Cache)that raises ongetandsetreplaces the cache. Five tests check that while the cache is down:None, notFalse);These cover the four exception handlers that previously had no tests (
_cache_get,_cache_set,record_mirror_verdict,known_mirror_verdict). Before this PR, making any of them re-raise passed every existing test.3. Migration
a7f3c2e91d84upgrade/downgrade (tests/unit_tests/migrations/test_add_partition_filter_mapping.py, 11 cases)Modelled on
test_add_deleted_at_to_tables.py. The tests check that:tables,table_columnsand their version tables;Refactor of an existing test:
test_epoch_bucket_queries_preserve_actual_rowsnow builds its transform and filters with the shared helpers_epoch_bucket_transform/_epoch_bucket_filter(the same code, moved), and_querytakes its defaults from_query_obj. To prove nothing changed, I recorded every SQL string the test generates (28 cases × mirrored and unmirrored, 56 in total) on master and on this branch: they are identical, and the 28 collected case IDs match.Question for maintainers: a failed cache read (
_cache_get,known_mirror_verdict) returnsNonewithout logging, while a failed write logs a warning. Is that intended? The tests don't depend on either answer: they assert that write failures are logged and don't count warnings. I checked this by temporarily adding read-failure warnings to production code; all cache-outage tests still passed.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A (tests only).
Coverage of
superset/connectors/sqla/partition_mapping.py(coverage run --branchover the partition-mapping unit test files):Newly covered: lines 2664-2665, 2672-2673, 2769-2770, 2786-2787 (the cache exception handlers). Nothing became newly uncovered.
Mutation checks. Each change was applied temporarily to production code, then reverted:
handle_comparison_filterwrites the key as a stringThe new Hive/Impala test still passes when only the rendering changes: Hive identifiers left unquoted, or explicit
(a AND b) OR cparentheses.TESTING INSTRUCTIONS
The Impala cases need the
impyladialect. CI installs.[hive,impala], so they run there. Locally they are skipped when impyla is missing.The touched files also pass in random order (pytest-randomly, 5 seeds) and under
pytest-xdist.ADDITIONAL INFORMATION
Test-only: adds unit tests for an existing migration (
a7f3c2e91d84) and does not add a migration.🤖 Generated with Claude Code