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 2 commits into
base: main
Choose a base branch
from

Conversation

boneanxs
Copy link
Contributor

Support Spark cast(integral to timestamp)

@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 c09a126
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/66f6907c8baea60008cf29b5

@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.

} else if (seconds < -maxSeconds) {
return Timestamp::fromMicros(std::numeric_limits<int64_t>::min());
}
return Timestamp::fromMillis(seconds * kMillisInSecond);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we create Timestamp with the constructor Timestamp(int64_t seconds, uint64_t nanos)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, let me fix it

makeNullableFlatVector<Timestamp>(
{Timestamp(0, 0),
Timestamp(1, 0),
Timestamp::fromMillis(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto.

// 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
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