Skip to content

[CALCITE-4771] add TRY_CAST function (enabled in MSSQL library)#3136

Closed
zoudan wants to merge 2 commits intoapache:mainfrom
zoudan:CALCITE-4771
Closed

[CALCITE-4771] add TRY_CAST function (enabled in MSSQL library)#3136
zoudan wants to merge 2 commits intoapache:mainfrom
zoudan:CALCITE-4771

Conversation

@zoudan
Copy link
Contributor

@zoudan zoudan commented Mar 30, 2023

add TRY_CAST function (enabled in MSSQL library)


/** Tests that CAST and SAFE_CAST are basically equivalent but SAFE_CAST is
* only available in BigQuery library. */
@Test void testCastVsSafeCast() {
Copy link
Contributor

Choose a reason for hiding this comment

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

adding a dialect udf shouldn't have touched so many existing tests, can you explain why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I want to reuse most of the test code for CAST and SAFE_CAST, just like what we did in
#3093

Copy link
Contributor

Choose a reason for hiding this comment

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

in my understanding parameterized tests are better suited for this.
I'd suggest some refactoring into these tests. let's see what others think

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case the behavior of the functions (SAFE_CAST, TRY_CAST) are identical, it is just named differently across dialects, so I am a fan of the code reuse.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zinking All the tests in this class are in form of parameterized test except testCastVsSafeCastVsTryCast, such as testCastToString, do you mean I also change this test into a parameterized one?

Copy link
Contributor

Choose a reason for hiding this comment

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

right, that would be better in my unserstanding

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zinking I have modified this, please have another look when you have time

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug C 1 Bug
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 9 Code Smells

90.9% 90.9% Coverage
0.0% 0.0% Duplication

@zinking
Copy link
Contributor

zinking commented Apr 17, 2023

I am +1 now, @olivrlee @libenchao can some of you let the CI go and merge if no other concerns

@libenchao
Copy link
Member

@zinking Thanks for your review, I've approved the CI, will go through the PR shortly, and will merge it if everything looks good to me.

Copy link
Member

@libenchao libenchao left a comment

Choose a reason for hiding this comment

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

+1, merging!

@zoudan Thanks for your contribution, and @zinking @olivrlee thanks for the review!

@libenchao libenchao closed this in 83f1361 Apr 17, 2023
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.

4 participants