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 Spark CAST(integral as timestamp) #11089

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

boneanxs
Copy link
Contributor

@boneanxs boneanxs commented Sep 25, 2024

Add Spark CAST (integral as timestamp). The input value is treated as the
number of seconds since the epoch (1970-01-01 00:00:00 UTC). Supported types
are tinyint, smallint, integer and bigint.

Spark's implementation: https://github.com/apache/spark/blob/v3.5.1/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala#L680

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 25, 2024
Copy link

netlify bot commented Sep 25, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 265e1c5
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/670884ed01ee6700083a58bb

@boneanxs
Copy link
Contributor Author

Hey @rui-mo, could you please help review this?

Copy link
Collaborator

@rui-mo rui-mo left a comment

Choose a reason for hiding this comment

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

Thanks.

velox/functions/sparksql/specialforms/SparkCastHooks.cpp Outdated Show resolved Hide resolved
velox/functions/sparksql/tests/SparkCastExprTest.cpp Outdated Show resolved Hide resolved
// Ensure that other integral types cast to int64 work as well.
testIntegralToTimestampCast<int8_t>();
testIntegralToTimestampCast<int16_t>();
testIntegralToTimestampCast<int32_t>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder why we adopt different test methods for int64_t and the others. Is there any special consideration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

since other integral types can't test large timestamp values, and since we only need to ensure cast smaller integral to int64_t works well, so here I adopt different test methods

@rui-mo rui-mo changed the title Add conversion from integral to timestamp Add Spark CAST(integral as timestamp) Sep 27, 2024
Copy link
Collaborator

@rui-mo rui-mo left a comment

Choose a reason for hiding this comment

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

Thanks. Just several nits.

velox/functions/sparksql/specialforms/SparkCastHooks.cpp Outdated Show resolved Hide resolved
velox/functions/sparksql/specialforms/SparkCastHooks.cpp Outdated Show resolved Hide resolved
velox/functions/sparksql/specialforms/SparkCastHooks.h Outdated Show resolved Hide resolved
velox/functions/sparksql/tests/SparkCastExprTest.cpp Outdated Show resolved Hide resolved
velox/functions/sparksql/tests/SparkCastExprTest.cpp Outdated Show resolved Hide resolved
@boneanxs boneanxs force-pushed the support_number_to_timestamp branch 2 times, most recently from 1dac228 to 18ce96d Compare October 10, 2024 03:07
@boneanxs boneanxs requested a review from rui-mo October 10, 2024 06:55
@rui-mo
Copy link
Collaborator

rui-mo commented Oct 12, 2024

cc: @pedroerp @mbasmanova If you have any more comment. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants