Skip to content

Conversation

chenzl25
Copy link
Contributor

@chenzl25 chenzl25 commented Jul 1, 2025

Which issue does this PR close?

  • Previously, we used record_batch.with_schema(target_schema.clone()) to change the schema name of a record batch, but unfortunately, with_schema would check the schema name and throw an error. So I think we should convert the RecordBatch like how BatchTransform::Modify does, but keep the same columns.
    pub fn with_schema(self, schema: SchemaRef) -> Result<Self, ArrowError> {
        if !schema.contains(self.schema.as_ref()) {
            return Err(ArrowError::SchemaError(format!(
                "target schema is not superset of current schema target={schema} current={}",
                self.schema
            )));
        }

        Ok(Self {
            schema,
            columns: self.columns,
            row_count: self.row_count,
        })
    }
  • Closes #.

What changes are included in this PR?

Are these changes tested?

Copy link
Contributor

@liurenjie1024 liurenjie1024 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chenzl25 for this pr, LGTM!

@liurenjie1024 liurenjie1024 merged commit 8edd708 into apache:main Jul 1, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants