Skip to content

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

Open
hqbhoho wants to merge 1 commit intolinkedin:masterfrom
hqbhoho:feature/convert_cast_2_try_cast
Open

[Coral-Trino] use 'TRY_CAST' instead of 'CAST'#544
hqbhoho wants to merge 1 commit intolinkedin:masterfrom
hqbhoho:feature/convert_cast_2_try_cast

Conversation

@hqbhoho
Copy link
Copy Markdown
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
Copy Markdown
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