Skip to content

Conversation

@zml1206
Copy link
Contributor

@zml1206 zml1206 commented Nov 18, 2025

Support legacy date formatter for Spark date_format function.

@netlify
Copy link

netlify bot commented Nov 18, 2025

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit c2aa59f
🔍 Latest deploy log https://app.netlify.com/projects/meta-velox/deploys/692fdfd0596fef00082e863a

@meta-cla meta-cla 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 Nov 18, 2025
@zml1206
Copy link
Contributor Author

zml1206 commented Nov 18, 2025

image

case 'S':
builder.appendFractionOfSecond(count);
break;
case 'u':
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure why this function is in functions/lib, looks like this function is only used in Spark. CC @rui-mo

And this behavior is not supported in Presto because it always uses joda time.
If we move it to Spark folder, we can safely change it to spark specified behavior.

presto:default> SELECT format_datetime(TIMESTAMP '1970-01-01', 'u');
Query 20251118_104605_00011_2tw34 failed: Illegal pattern component: u

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The historical reasons are unclear, it may be for the purpose of centralizing all formatters.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure why this function is in functions/lib, looks like this function is only used in Spark

Hi @NEUpanning, do you have any input on this? I only found #10354 but it doesn’t explain why the simple formatter cannot be Spark-specific.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought formatters which could be reused should in functions/lib when I saw mysql formatter is only used by presto yet remains in functions/lib.

break;
case 'u':
builder.appendDayOfWeek1Based(count);
break;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Keep alphabetical order

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't move it, they are all appendDayOfWeekxxx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It wasn't removed, it was just moved to the bottom.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe it placed here because the next is appendDayOfWeekText, both way can be acceptable, integrate with appendDayOfWeekxxx or alphabetical order

if (!isConstFormat_) {
auto formatter = detail::initializeFormatter(
std::string_view(formatString), legacyFormatter_);
if (formatter) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if (!formatter) {
  return false;

}
formatter_ = formatter;
maxResultSize_ = formatter_->maxResultSize(sessionTimeZone_);

Copy link
Collaborator

@jinchengchenghh jinchengchenghh left a comment

Choose a reason for hiding this comment

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

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.

@rui-mo rui-mo added the ready-to-merge PR that have been reviewed and are ready for merging. PRs with this tag notify the Velox Meta oncall label Dec 2, 2025
@meta-codesync
Copy link

meta-codesync bot commented Dec 2, 2025

@xiaoxmeng has imported this pull request. If you are a Meta employee, you can view this in D88172777.

Copy link
Contributor

@xiaoxmeng xiaoxmeng left a comment

Choose a reason for hiding this comment

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

@zml1206 can you fix the build failures?

@zml1206
Copy link
Contributor Author

zml1206 commented Dec 3, 2025

@zml1206 can you fix the build failures?

It has been fixed in #15670

@zml1206
Copy link
Contributor Author

zml1206 commented Dec 5, 2025

The Spark fuzzer failure seems unrelated, do you know why? @rui-mo

@rui-mo
Copy link
Collaborator

rui-mo commented Dec 5, 2025

@zml1206 It appears to be the same issue described in #15697. We’ll look into it later.

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. ready-to-merge PR that have been reviewed and are ready for merging. PRs with this tag notify the Velox Meta oncall

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants