Repository navigation
[datafusion] Support materialized views over ordinary append tables - #1584
JingsongLi merged 1 commit into
Conversation
leaves12138
left a comment
There was a problem hiding this comment.
Reviewed base main at head ffcfe94 (+89/-23, 3 files): crates/integrations/datafusion/README.md, crates/integrations/datafusion/src/sql_context.rs, docs/src/sql.md.
This is the DataFusion registration counterpart of apache/paimon#11670 (already merged): the source gate in materialized_view_planning_catalogs replaces the data_evolution_enabled() requirement with !table_schema.primary_keys().is_empty() rejection, so any Paimon append table (with or without row tracking / Data Evolution) can back a materialized view. No core crate changes; the relaxation is confined to the DataFusion SQL layer, and refresh semantics stay owned by Spark.
Analysis:
- The remaining guards are preserved:
TableType::Table(no nested materialized/format tables), no time-travel selector (branch head only), and no query authorization. Primary-key tables are now the explicit rejection criterion, which matches the Spark-sideAppendOnlyFileStoreTablegate; a PK table withwrite-onlyor DV configurations can no longer slip through as an append source. - The backing table creation is unchanged: DE + row tracking + DV, bucket -1, Parquet,
materialized-table.definition-query, reservedsource_row_idoutput check, and the double-quote token rejection all still apply, so views registered here remain refreshable by Spark under the same contract as before. - Planning still registers
EmptyTableschemas from physical columns only, so wildcard expansion and name resolution match Spark refresh behavior for ordinary append sources as well. - Tests cover the three supported shapes from #11670 (filtered projection, GROUP BY over a fixed-bucket partitioned append source, inner join with a DE peer), assert the stored definition query and materialized-table options, and verify rejection of primary-key, historical-read, and query-authorized sources plus the no-source case. The error messages are updated consistently in both the code and the tests.
- Docs correctly state the supported query shapes, the with/without row tracking support, and the connector requirement (a build including #11670, Spark 4.1/4.2/4.3).
No findings. The author reports all 461 paimon-datafusion library tests, fmt checks, and a local Filesystem Catalog smoke test with Spark 4.1.4 (first refresh, second refresh after appends, DataFusion readback) passing.
CI note: all checks green (builds and units on Linux/macOS/Windows, all integration suites including datafusion, MSRV, check).
LGTM.
Purpose
Allow DataFusion to register materialized views over ordinary Paimon append tables. Spark can refresh these views against the same catalog and warehouse. Apache Paimon #11670
Brief change log
Tests
paimon-datafusionlibrary tests passed.cargo fmt --all -- --checkandgit diff --checkpassed.API and Format
CREATE MATERIALIZED VIEWderives the output schema and creates an empty Parquet Data Evolution backing table with deletion vectors. Spark populates and refreshes it.Documentation
Updated the SQL guide and DataFusion README to describe ordinary append sources and the Spark connector requirement.