alamb opened a new issue, #14383:
URL: https://github.com/apache/datafusion/issues/14383

   ### Describe the bug
   
   Found while working on
   - https://github.com/apache/datafusion/issues/14154 it may be the same
   
   When two structs are coerced as part of case, the field names are lost (set 
to `c0`)
   
   
   ### To Reproduce
   
   ```sql
   create table t as values
   (
    100,                                      -- column1 int (so the case isn't 
constant folded)
    { 'foo': 'bar' },                         -- column2 has List of Struct w/ 
Utf8
    { 'foo': arrow_cast('baz', 'Utf8View') }  -- column3 has List of Struct w/ 
Utf8View
   );
   
    -- fields are correctly names 'foo'
   SELECT column2, column3  FROM t;
   
   -- +------------+------------+
   -- | column2    | column3    |
   -- +------------+------------+
   -- | {foo: bar} | {foo: baz} |
   -- +------------+------------+
   -- 1 row(s) fetched.
   
   -- When coerced the field name turns into `c0` should be `foo`
   SELECT case when column1 > 0 then column2 else column3 end FROM t;
   
   -- +------------------------------------------------------------------+
   -- | CASE WHEN t.column1 > Int64(0) THEN t.column2 ELSE t.column3 END |
   -- +------------------------------------------------------------------+
   -- | {c0: bar}                                                        |
   -- +------------------------------------------------------------------+
   ```
   
   
   
   ### Expected behavior
   
   The results should be
   
   ```sql
   {foo: bar}
   ```
   
   
   ### Additional context
   
   _No response_


-- 
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: github-unsubscr...@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to