Skip to content

Case coercion of Structs loses field names  #14383

Closed

Description

@alamb

Describe the bug

Found while working on

When two structs are coerced as part of case, the field names are lost (set to c0)

To Reproduce

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

{foo: bar}

Additional context

No response

Activity

  1. added
    bugSomething isn't working
    regressionSomething that used to work no longer does
    on Jan 31, 2025
  2. changed the title [-]`Case` coercion of Structs loses field names (regression introduced in DataFusion 44)[/-] [+]`Case` coercion of Structs loses field names [/+] on Jan 31, 2025
  3. removed
    regressionSomething that used to work no longer does
    on Jan 31, 2025
  4. alamb commented on Jan 31, 2025

    @alamb
    ContributorAuthor

    Actually I tested this in DataFuson 43 and it also fails

  5. ion-elgreco commented on Jan 31, 2025

    @ion-elgreco

    I have actually seen this, but thought it was a visual bug 😮

  6. alamb commented on Jan 31, 2025

    @alamb
    ContributorAuthor

    We'll get it fixed

  7. alamb commented on Jan 31, 2025

    @alamb
    ContributorAuthor
  8. self-assigned this
    on Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions