grorge123 opened a new issue, #7380:
URL: https://github.com/apache/datafusion-comet/issues/7380

   ### Describe the bug
   
   `GetStructField` (`native/spark-expr/src/struct_funcs/get_struct_field.rs`) 
returns a one-row array when its input is a scalar struct. A projection or 
expression that combines that field with a column then fails, because the 
one-row array does not match the batch's row count. Native evaluates a struct 
as a scalar when all its inputs are scalars, for example `named_struct` over a 
scalar subquery, or a cast of one.
   
   ### Steps to reproduce
   
   One Parquet file, so the four rows share a batch:
   
   ```sql
   CREATE TABLE t(a int) USING parquet;
   INSERT INTO t SELECT /*+ REPARTITION(1) */ * FROM VALUES (1), (-1), (NULL), 
(4) AS v(a);
   
   SELECT a, CAST(named_struct('x', (SELECT max(a) FROM t)) AS STRUCT<x: 
BIGINT>).x FROM t;
   ```
   
   On `main` at c4a0b1f2b (Spark 4.1 profile), the query fails with 
`CometNativeException: Array length 1 does not match expected length 4`.
   
   ### Expected behavior
   
   The field is one value for every row, as in Spark: `4` for each of the four 
rows.
   
   ### Additional context
   
   Found while working on #5526. The query needs several rows in one batch; 
with one row per batch, the lengths happen to match.
   
   Assisted-by: Claude Code (claude-opus-5-5)
   


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