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

Invalid format returns null for legacy date formatter #11131

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

Conversation

NEUpanning
Copy link
Contributor

Invalid format returns null for Spark functions that use legacy(Simple) date formatter to align with SparkSQL behavior. Included functions are : 'unix_timestamp', 'from_unixtime' and 'get_timestamp'.

Relates #10354

@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 30, 2024
Copy link

netlify bot commented Sep 30, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 4fa2261
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/6707b68cab49880008acb334

@NEUpanning
Copy link
Contributor Author

@rui-mo Could you help to review this PR please? Thanks.

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.

kDefaultFormat_,
config.sparkLegacyDateFormatter() ? DateTimeFormatterType::STRICT_SIMPLE
: DateTimeFormatterType::JODA);
// Default format should always be valid.
VELOX_CHECK_EQ(formatter.hasError(), false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

VELOX_CHECK(!formatter.hasError());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Updated.

invalidFormat_ = true;
} else {
this->format_ = formatter.value();
}
} catch (const VeloxUserError&) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wound be nice to make buildJodaDateTimeFormatter return Expected so getDateTimeFormatter does not throw exception and the try-catch clause can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your suggestion. Done.

std::string_view(format.data(), format.size()),
legacyFormatter_ ? DateTimeFormatterType::STRICT_SIMPLE
: DateTimeFormatterType::JODA);
if (formatter.hasError()) {
return false;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Exception from 'buildJodaDateTimeFormatter' is not handled, so it shall work here if 'buildJodaDateTimeFormatter' returns Expected.

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