Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case coercion of Structs loses field names #14383

Closed
Tracked by #14375
alamb opened this issue Jan 31, 2025 · 4 comments · Fixed by #14384
Closed
Tracked by #14375

Case coercion of Structs loses field names #14383

alamb opened this issue Jan 31, 2025 · 4 comments · Fixed by #14384
Assignees
Labels
bug Something isn't working

Comments

@alamb
Copy link
Contributor

alamb commented Jan 31, 2025

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

@alamb alamb added the bug Something isn't working label Jan 31, 2025
@alamb alamb added the regression Something that used to work no longer does label Jan 31, 2025
@alamb alamb changed the title Case coercion of Structs loses field names (regression introduced in DataFusion 44) Case coercion of Structs loses field names Jan 31, 2025
@alamb alamb removed the regression Something that used to work no longer does label Jan 31, 2025
@alamb
Copy link
Contributor Author

alamb commented Jan 31, 2025

Actually I tested this in DataFuson 43 and it also fails

@ion-elgreco
Copy link

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

@alamb
Copy link
Contributor Author

alamb commented Jan 31, 2025

We'll get it fixed

@alamb
Copy link
Contributor Author

alamb commented Jan 31, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants