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

Add cast functions for char datatype to numeric types #23792

Merged

Conversation

elbinpallimalilibm
Copy link
Contributor

@elbinpallimalilibm elbinpallimalilibm commented Oct 9, 2024

Description

Add CAST functions for CHAR datatype to different numeric datatypes.

Motivation and Context

Impact

Test Plan

Contributor checklist

  • Please make sure your submission complies with our development, formatting, commit message, and attribution guidelines.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== RELEASE NOTES ==

General Changes
* Added support for casting char datatype to various numeric datatypes.     :pr:`23792`

@elbinpallimalilibm elbinpallimalilibm requested a review from a team as a code owner October 9, 2024 15:06
@tdcmeehan tdcmeehan self-assigned this Oct 9, 2024
@@ -192,4 +198,21 @@ public void testIndeterminate()
assertOperator(INDETERMINATE, "CAST(null AS CHAR(3))", BOOLEAN, true);
assertOperator(INDETERMINATE, "CHAR '123'", BOOLEAN, false);
}

@Test
public void testCharCast()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add some test cases for the following:

  1. some numbers without whitespace
  2. What happens when the number is outside of the range of values for integer/float
  3. Any support for nan or infinity
  4. any support for hexidecimal numbers
  5. Any support for hexidecimal floating point numbers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some more tests. There is no support for hexa decimal numbers now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could probably add support for hexadecimals by considering any char(x) type prefixed with 0x as a hexadecimal, but I'm not sure if that will be an unintended output for those who use the cast function

@steveburnett
Copy link
Contributor

Nit to include the PR number in the release note entry, following the Release Notes Guidelines.

== RELEASE NOTES ==

General Changes
* Add support for casting char datatype to various numeric datatypes.  :pr:`23792`

@tdcmeehan tdcmeehan merged commit 9fa4aee into prestodb:master Oct 10, 2024
56 checks passed
@elbinpallimalilibm elbinpallimalilibm deleted the cast-char-to-numeric-types branch October 10, 2024 14:21
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.

3 participants