rich7420 commented on code in PR #6246:
URL: https://github.com/apache/datafusion-comet/pull/6246#discussion_r4706279902


##########
native/core/src/parquet/schema_adapter.rs:
##########
@@ -1409,6 +1447,100 @@ impl SparkPhysicalExprAdapter {
         .data()
     }
 
+    /// A `binaryAsString` scan reads string columns as Binary and decodes 
them to strings with a
+    /// Spark cast, in its output projection and in the filters it pushes. 
Where arrow-rs reads
+    /// the column as Utf8, the default adapter makes that `CAST(CAST(s AS 
BINARY) AS STRING)`.
+    /// Use the column itself to skip both casts and let filters prune. This 
preserves the
+    /// setting-off behavior: arrow-rs validates UTF8-annotated columns, but 
JSON annotations and
+    /// Utf8 `ARROW:schema` hints can still yield unchecked string arrays.
+    fn unwrap_binary_round_trip(
+        &self,
+        expr: Arc<dyn PhysicalExpr>,
+    ) -> DataFusionResult<Transformed<Arc<dyn PhysicalExpr>>> {
+        if let Some(cast) = expr.downcast_ref::<Cast>() {
+            if cast.data_type == DataType::Utf8 {
+                if let Some((column, DataType::Utf8)) = 
self.column_cast_to_binary(&cast.child) {

Review Comment:
   Could `ENUM` keep pruning here despite arrow-rs reading it as `Binary`? With 
`binaryAsString` on, `value < 'two'` pruned one row group for me, versus two 
with it off.



##########
docs/source/user-guide/latest/parquet.md:
##########
@@ -292,11 +298,13 @@ for production, so do not turn it off to avoid an entry 
on this page.
 - **BINARY values that are not valid UTF-8, read as STRING.** This applies to 
a BINARY column
   without the UTF8 annotation that is read as `string`, through the read 
schema or
   `spark.sql.parquet.binaryAsString=true`. Spark keeps the bytes. In a struct 
field, list element
-  or map value, Comet replaces each ill-formed sequence with `U+FFFD`, as 
described in
-  [Strings with non-UTF-8 
bytes](compatibility/index.md#strings-with-non-utf-8-bytes). Top-level
-  values, and map keys at any depth, reach an Arrow string array unchecked, 
which keeps keys that
-  differ only in such bytes distinct: they match Spark in a release build, and 
a debug build
-  panics on top-level values 
([#7032](https://github.com/apache/datafusion-comet/issues/7032), part of
+  or map value, and at the top level with 
`spark.sql.parquet.binaryAsString=true`, Comet replaces

Review Comment:
   Could this bullet and the one in `compatibility/index.md` mention that 
top-level columns with a `Utf8` `ARROW:schema` hint are read unchecked with 
`binaryAsString` on?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to