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
use object_store::{ObjectStore,ObjectStoreExt,PutPayload};
44
44
45
45
// Example showing how to implement custom casting rules to adapt file schemas.
46
-
// This example enforces that casts must be strictly widening: if the file type is Int64 and the table type is Int32, it will error
47
-
// before even reading the data.
48
-
// Without this custom cast rule DataFusion would happily do the narrowing cast, potentially erroring only if it found a row with data it could not cast.
46
+
// This example enforces strictly widening casts: if the file type is Int64 and
47
+
// the table type is Int32, it errors before reading the data. Without this
48
+
// custom cast rule DataFusion would apply the narrowing cast and might only
49
+
// error after reading a row that it could not cast.
49
50
pubasyncfncustom_file_casts() -> Result<()>{
50
51
println!("=== Creating example data ===");
51
52
@@ -139,7 +140,7 @@ async fn write_data(
139
140
Ok(())
140
141
}
141
142
142
-
/// Factory for creating DefaultValuePhysicalExprAdapter instances
143
+
/// Factory for creating custom cast physical expression adapters
143
144
#[derive(Debug)]
144
145
structCustomCastPhysicalExprAdapterFactory{
145
146
inner:Arc<dynPhysicalExprAdapterFactory>,
@@ -167,8 +168,8 @@ impl PhysicalExprAdapterFactory for CustomCastPhysicalExprAdapterFactory {
167
168
}
168
169
}
169
170
170
-
/// Custom PhysicalExprAdapter that handles missing columns with default values from metadata
171
-
/// and wraps DefaultPhysicalExprAdapter for standard schema adaptation
171
+
/// Custom `PhysicalExprAdapter` that wraps the default adapter and rejects
// First delegate to the inner adapter to handle missing columns and discover any necessary casts
181
+
// First delegate to the inner adapter to handle standard schema adaptation
182
+
// and discover any necessary casts.
181
183
expr = self.inner.rewrite(expr)?;
182
-
// Now we can apply custom casting rules or even swap out all CastExprs for a custom cast kernel / expression
183
-
// For example, [DataFusion Comet](https://github.com/apache/datafusion-comet) has a [custom cast kernel](https://github.com/apache/datafusion-comet/blob/b4ac876ab420ed403ac7fc8e1b29f42f1f442566/native/spark-expr/src/conversion_funcs/cast.rs#L133-L138).
184
+
// Now apply custom casting rules or swap CastExprs for a custom cast
185
+
// kernel / expression. For example, DataFusion Comet has a custom cast
186
+
// kernel in its native Spark expression implementation.
0 commit comments