Rich-T-kid opened a new issue, #26170:
URL: https://github.com/apache/datafusion/issues/26170

   `substr` on a dictionary-encoded string column plans an implicit cast to 
`Utf8View`, materializing the dictionary before the scalar function runs. The 
dict's row-dedup is discarded — `substr` processes `N_rows` strings instead of 
`N_distinct` values.
   
   Repro (datafusion-cli 54.0.0):
   
   ```sql
   CREATE TABLE t AS
   SELECT arrow_cast('hello' || i::VARCHAR, 'Dictionary(Int32, Utf8)') AS k
   FROM generate_series(1, 10) AS s(i);
   
   EXPLAIN SELECT substr(k, 1, 4) FROM t;
   ```
   
   Plan:
   
   ```
   ProjectionExec: expr=[substr(CAST(k@0 AS Utf8View), 1, 4) as 
substr(t.k,Int64(1),Int64(4))]
     DataSourceExec: ...
   ```
   
   The arrow-rs `substring` kernel already handles this by delegating to 
`dictionary.values()` and reusing the keys 
(`arrow-string/src/substring.rs:79-82`). `SubstrFunc`'s signature in 
`datafusion/functions/src/unicode/substr.rs` doesn't advertise `Dictionary` 
support, so type coercion inserts the cast.
   


-- 
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