NoahKusaba opened a new issue, #2963:
URL: https://github.com/apache/datafusion-ballista/issues/2963

   **Describe the bug**
   
   When a query's output has a dictionary-encoded column, the batches the 
client gets have the value type instead (`Utf8` for `Dictionary(Int32, Utf8)`), 
while `DataFrame::schema()` and the plan say `Dictionary`. This happens with 
both planners.
   
   Anything that checks batches against the plan's schema then fails. For 
example, `CREATE TABLE … AS SELECT arrow_cast(x, 'Dictionary(Int32, Utf8)') …` 
fails with `Mismatch between schema and batches`, and DataFusion's sqllogictest 
runner fails with `Schema mismatch`.
   
   **To Reproduce**
   
   Standalone Ballista on `main` (446fa54c9), default settings:
   
   ```rust
   let df = ctx.sql("SELECT arrow_cast(column1, 'Dictionary(Int32, Utf8)') AS c 
FROM (VALUES ('a'), ('b'), ('a'))").await?;
   let plan_schema = df.schema().as_arrow().clone();   // c: Dictionary(Int32, 
Utf8)
   let batches = df.collect().await?;
   assert_eq!(batches[0].schema().field(0).data_type(), 
plan_schema.field(0).data_type());
   // fails: Utf8 != Dictionary(Int32, Utf8)
   ```
   
   It also happens for nested types, for example `array_agg` over a dictionary 
column comes back as `List(Utf8)`.
   
   **Expected behavior**
   
   The batches keep the dictionary type, matching the plan's schema.
   
   **Additional context**
   
   Found by running DataFusion's sqllogictest files on Ballista (#2945). It's 
the second-largest group there: 145 records, plus most of 377 later "table not 
found" failures, where a `CREATE TABLE AS` with a dictionary column had failed.
   
   A likely cause, not yet confirmed: in 
`ballista/executor/src/flight_service.rs` the sort-shuffle `FetchPartition` 
path builds its `FlightDataEncoderBuilder` without 
`.with_dictionary_handling(DictionaryHandling::Resend)`, so the default 
`Hydrate` decodes dictionaries. The pipelined path sets `Resend`, with a 
comment explaining why.
   


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