Skip to content

Conversation

@deniskuzZ
Copy link
Member

@deniskuzZ deniskuzZ commented Nov 11, 2025

What changes were proposed in this pull request?

Create the ObjectInspector according to the specified target type

Why are the changes needed?

Filter on non-String value fails

Does this PR introduce any user-facing change?

No

How was this patch tested?

qtest

@sonarqubecloud
Copy link

Copy link
Member

@ayushtkn ayushtkn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanx @deniskuzZ for the fix, the prod changes looks good. I think it isn't filtering broken, it is the UDF broken in case of type casting.

this query will fail without the fix, nothing around filtering

select try_variant_get(parse_json('{"a": 1}'), '$.a', 'int')

we must change the title to reflect that and maybe rather than testing the filtering, we might add tests around different types of casting.

Regarding filtering, I tried this

SELECT
  try_variant_get(data, '$.name') AS name,
  try_variant_get(data, '$.age', 'int') AS age,
  try_variant_get(data, '$.address.city') AS city
FROM variant_filter_basic
WHERE CAST(try_variant_get(data, '$.age') AS INT) >= 30;

this works, so filtering isn't broken, the UDF cast functionality is broken

@deniskuzZ deniskuzZ changed the title HIVE-29310: Filtering on Variant columns HIVE-29310: Type casting problem in the variant_get UDF Nov 17, 2025
@deniskuzZ
Copy link
Member Author

@ayushtkn, @difin should we include this in 4.2? there is already a blog by Ayush on this, so probably we don't want for users to encounter this issue

@ayushtkn
Copy link
Member

If possible to include, it would be very nice

@deniskuzZ
Copy link
Member Author

deniskuzZ commented Nov 17, 2025

If possible to include, it would be very nice

please +1, or i need to fix something (updated the title)?

btw it didn't fail in variant_type.q. I don't have exception at hand but it was failing because constant in predicate and value had different types.

SELECT
    variant_get(data, '$', 'int') as as_int,
```

Copy link
Member

@ayushtkn ayushtkn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@deniskuzZ deniskuzZ merged commit e34e87f into apache:master Nov 17, 2025
2 checks passed
deniskuzZ added a commit that referenced this pull request Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants