eschutho opened a new pull request, #44431:
URL: https://github.com/apache/superset/pull/44431

   ### SUMMARY
   
   The partition filter mapping feature (the 6-PR stack this builds on) lets a
   chart author's filter on one column be mirrored onto a table's physical
   partition column so Hive/Impala-family engines can prune partitions. PR
   #43891 made the *transform pre-fill* engine-aware by adding
   `BaseEngineSpec.partition_value_transform_default`, set to
   `unix_timestamp(:value)` on `HiveEngineSpec`/`ImpalaEngineSpec` (Spark
   inheriting from Hive) and deliberately left `None` on Presto.
   
   That only decides **which default transform to suggest**, not **whether the
   feature should be offered at all**. There was no per-engine gate:
   
   - The editor gate in `DatasourceEditor.tsx` was
     `isFeatureEnabled(FeatureFlag.PartitionFilterMapping) && 
Boolean(datasource)`
     -- the "Partition column" dropdown appeared on **every** database whenever
     the flag was on.
   - `validate_partition_mapping` receives `engine=database.backend` but only
     uses it to check the transform text parses for that dialect, never to
     reject the feature on engines where partition-directory pruning does not
     structurally apply.
   
   So a Postgres, Snowflake, BigQuery or Redshift dataset showed the exact same
   "Partition column" UI as an Impala one. Mirroring a filter onto a physical
   partition column only prunes work on engines whose tables are laid out as
   partition directories (Hive-family). On Postgres the concept does not exist;
   Snowflake micro-partitions are automatic and invisible; BigQuery and Redshift
   use different mechanisms entirely. There the dropdown is clutter that maps to
   nothing.
   
   **The fix** adds a capability flag that travels alongside the existing
   transform default, on exactly the same engines:
   
   - `BaseEngineSpec.supports_partition_filter_mapping: bool = False`, set
     `True` on `HiveEngineSpec` and `ImpalaEngineSpec`; `SparkEngineSpec`
     inherits it from Hive. Presto/Trino and everything else stay `False`,
     matching the decision that left `partition_value_transform_default` off
     Presto.
   - Threaded to the client the identical way the transform default is: a
     read-only `SqlaTable.supports_partition_filter_mapping` property sourced
     from the engine spec, exposed via `DatasetRestApi.show_columns`, and added
     to the frontend datasource types.
   - The editor's `partitionMappingEnabled` gate now also requires the flag, so
     the partition mapping UI only appears on an engine that advertises support.
   
   This PR is scoped to the capability gate only; it does not change the mapping
   logic, the transform default, or the set of in-scope engines.
   
   The first commit (`style(explore): apply oxfmt to the datasource editor`) is 
a
   no-op reformat: the `<CollectionTable>` block in `DatasourceEditor.tsx` was
   indented one level short of its wrapper and `oxfmt` flags it, so any change
   touching the file has to reformat it. It is split out so the capability-gate
   diff stays reviewable.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A -- the observable change is the absence of the "Partition column" section
   in the dataset editor's Columns tab on engines that do not support partition
   directories (e.g. Postgres), while it continues to appear on 
Hive/Impala/Spark.
   
   ### TESTING INSTRUCTIONS
   
   1. Enable the `PARTITION_FILTER_MAPPING` feature flag.
   2. Open the dataset editor for a Hive, Impala or Spark dataset -> the
      partition filter mapping controls appear.
   3. Open the dataset editor for a Postgres (or Snowflake/BigQuery/Redshift)
      dataset -> the partition filter mapping controls are no longer offered.
   
   Automated:
   
   - `pytest tests/unit_tests/db_engine_specs/test_hive.py
     tests/unit_tests/db_engine_specs/test_impala.py
     tests/unit_tests/datasets/partition_mapping_serialization_test.py`
   - `npm run test -- src/components/Datasource/components/DatasourceEditor`
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [x] Required feature flags: `PARTITION_FILTER_MAPPING`
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to