Skip to content

Commit

Permalink
fix partition column name collision
Browse files Browse the repository at this point in the history
  • Loading branch information
JanKaul committed Oct 21, 2024
1 parent ab21d34 commit 4ad5529
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion datafusion_iceberg/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,18 @@ impl ExtensionPlanner for CreateIcebergTablePlanner {
.enumerate()
.map(|(i, x)| {
let (column, transform) = parse_transform(x)?;
let name = if let Transform::Identity = &transform {
column.clone()
} else {
column.clone() + "_" + &transform.to_string()
};
Ok::<_, Error>(PartitionField::new(
schema
.get_name(&column)
.ok_or(Error::NotFound("Column".to_owned(), column.clone()))?
.id,
1000 + i as i32,
&(column + "_" + &transform.to_string()),
&name,
transform,
))
})
Expand Down
4 changes: 2 additions & 2 deletions datafusion_iceberg/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ async fn table_scan(
.map(|field| {
let struct_field = schema.fields().get(*field.source_id() as usize).unwrap();
Ok(Field::new(
field.name().clone(),
field.name().clone() + "__partition",
(&struct_field
.field_type
.tranform(field.transform())
Expand All @@ -484,7 +484,7 @@ async fn table_scan(
for partition_field in table.metadata().default_partition_spec().unwrap().fields() {
schema_builder.with_struct_field(StructField {
id: *partition_field.field_id(),
name: partition_field.name().clone(),
name: partition_field.name().clone() + "__partition",
field_type: schema
.fields()
.get(*partition_field.source_id() as usize)
Expand Down

0 comments on commit 4ad5529

Please sign in to comment.