Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions kernel/src/transaction/builder/create_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ const ALLOWED_DELTA_FEATURES: &[TableFeature] = &[
// the feature on an all-nullable table so a later ALTER TABLE ADD COLUMN NOT NULL does
// not need a protocol upgrade.
TableFeature::Invariants,
// MaterializePartitionColumns keeps partition columns in the data files instead of
// dropping them on write. There is no `delta.*` enablement property; the only opt-in at
// create time is the explicit feature signal
// `delta.feature.materializePartitionColumns=supported`.
TableFeature::MaterializePartitionColumns,
];

/// Delta properties allowed to be set during CREATE TABLE.
Expand Down
7 changes: 7 additions & 0 deletions kernel/tests/create_table/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,13 @@ async fn test_create_table_txn_debug() -> DeltaResult<()> {
#[case("appendOnly", TableFeature::AppendOnly, false, false)]
#[case("changeDataFeed", TableFeature::ChangeDataFeed, false, false)]
#[case("rowTracking", TableFeature::RowTracking, false, false)]
// WriterOnly features (AlwaysIfSupported)
#[case(
"materializePartitionColumns",
TableFeature::MaterializePartitionColumns,
false,
true
)]
fn test_create_table_with_feature_signal(
#[case] feature_name: &str,
#[case] feature: TableFeature,
Expand Down
40 changes: 39 additions & 1 deletion kernel/tests/create_table/partitioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

use delta_kernel::committer::FileSystemCommitter;
use delta_kernel::snapshot::Snapshot;
use delta_kernel::table_features::TableFeature;
use delta_kernel::transaction::create_table::create_table;
use delta_kernel::transaction::data_layout::DataLayout;
use delta_kernel::DeltaResult;
use rstest::rstest;
use test_utils::test_table_setup;

use super::partition_test_schema;
use super::{partition_test_schema, simple_schema};

#[rstest]
#[case::exact_casing("date")]
Expand Down Expand Up @@ -39,3 +40,40 @@ fn test_create_table_partitioned_basic(#[case] partition_col: &str) -> DeltaResu

Ok(())
}

/// CREATE TABLE accepts `delta.feature.materializePartitionColumns=supported` regardless of
/// whether the table is partitioned. The feature is harmless on a non-partitioned table
/// (nothing to materialize) and Delta-Spark also does not error in that case, so kernel
/// matches that behavior.
#[rstest]
#[case::partitioned(true)]
#[case::non_partitioned(false)]
fn test_create_table_with_materialize_partition_columns_partitioned_and_not(
#[case] partitioned: bool,
) -> DeltaResult<()> {
let (_temp_dir, table_path, engine) = test_table_setup()?;
let schema = if partitioned {
partition_test_schema()?
} else {
simple_schema()?
};

let mut builder = create_table(&table_path, schema, "Test/1.0")
.with_table_properties([("delta.feature.materializePartitionColumns", "supported")]);
if partitioned {
builder = builder.with_data_layout(DataLayout::partitioned(["date"]));
}
let _ = builder
.build(engine.as_ref(), Box::new(FileSystemCommitter::new()))?
.commit(engine.as_ref())?;

let snapshot = Snapshot::builder_for(&table_path).build(engine.as_ref())?;
assert!(
snapshot
.table_configuration()
.is_feature_enabled(&TableFeature::MaterializePartitionColumns),
"MaterializePartitionColumns should be enabled (partitioned={partitioned})"
);

Ok(())
}
Loading