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

[Coral-Trino] use 'TRY_CAST' instead of 'CAST' #544

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hqbhoho
Copy link
Contributor

@hqbhoho hqbhoho commented Dec 18, 2024

What changes are proposed in this pull request, and why are they necessary?

Hive/Spark CAST is equivalent to Trino TRY_CAST. If CAST fails, a query using Hive/Spark will return null, while a query using Trino will throw error. So I think should use 'TRY_CAST' instead of 'CAST'.

  • Hive/Spark
    select cast('a' as int) return null
  • Trino
    select cast('a' as int) throw error like "Cannot cast 'a' to INT"
    select try_cast('a' as int) return null

How was this patch tested?

Modified unit tests.

@hqbhoho hqbhoho force-pushed the feature/convert_cast_2_try_cast branch 3 times, most recently from 7dcd49f to 7ba254b Compare December 19, 2024 01:26
@hqbhoho
Copy link
Contributor Author

hqbhoho commented Dec 19, 2024

@wmoustafa Could you help review it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant