You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem or challenge?
From conversation with Andrew a couple days ago he mentioned this was an open feature request however I could not find an issue. @alamb do you remember who else was asking for this?
We have an implementation of this internally, it actually is more generic because we use it to generate columns from other columns, but it covers the use case of default values and it would be easy to make that API simple.
Essentially we declare:
pubtraitMissingColumnGeneratorFactory:Debug + Send + Sync{/// Create a [`MissingColumnGenerator`] for the given `field` and `file_schema`./// Returns None if the column cannot be generated by this generator./// Otherwise, returns a [`MissingColumnGenerator`] that can generate the missing column.fncreate(&self,field:&Field,file_schema:&Schema,) -> Option<Arc<dynMissingColumnGenerator + Send + Sync>>;}pubtraitMissingColumnGenerator:Debug + Send + Sync{/// Generate a missing column for the given `field` from the provided `batch`./// When this method is called `batch` will contain all of the columns declared as dependencies in `dependencies`./// If the column cannot be generated, this method should return an error./// Otherwise, it should return the generated column as an `ArrayRef`./// No casting or post processing is done by this method, so the generated column should match the data type/// of the `field` it is being generated, otherwise an Err will be returned upstream./// There is no guarantee about the order of the columns in the provided RecordBatch.fngenerate(&self,batch:RecordBatch) -> datafusion_common::Result<ArrayRef>;/// Returns a list of column names that this generator depends on to generate the missing column./// This is used when creating the `RecordBatch` to ensure that all dependencies are present before calling `generate`./// The dependencies do not need to be declared in any particular order.fndependencies(&self) -> Vec<String>;}
And then you pass in one or more MissingColumnGeneratorFactory into SchemaAdapterFactory.
There was a lot of pain figuring out how to properly adjust projections to take into account the injected dependency columns, but we've done that work already on our end.
The other thing to note is that adjustments are needed in filter pushdown, specifically here:
The other thing to note is that adjustments are needed in filter pushdown
I’ll note that this is currently broken without any new features. I can give an example later but basically you make a custom SchemaMapper that eg instead of filling in nulls fills in default values. That’s doable with current public APIs. Then you get different behavior between filter push down and not.
Is your feature request related to a problem or challenge?
From conversation with Andrew a couple days ago he mentioned this was an open feature request however I could not find an issue. @alamb do you remember who else was asking for this?
We have an implementation of this internally, it actually is more generic because we use it to generate columns from other columns, but it covers the use case of default values and it would be easy to make that API simple.
Essentially we declare:
And then you pass in one or more
MissingColumnGeneratorFactory
intoSchemaAdapterFactory
.There was a lot of pain figuring out how to properly adjust projections to take into account the injected dependency columns, but we've done that work already on our end.
The other thing to note is that adjustments are needed in filter pushdown, specifically here:
datafusion/datafusion/datasource-parquet/src/row_filter.rs
Lines 355 to 384 in 8061485
This last bit applies no matter if simpler defaults are being generated or more complex derived columns.
The text was updated successfully, but these errors were encountered: