-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: Support legacy date formatter for Spark date_format function #15535
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for meta-velox canceled.
|
| case 'S': | ||
| builder.appendFractionOfSecond(count); | ||
| break; | ||
| case 'u': |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep alphabetical order
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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_);
jinchengchenghh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
rui-mo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
|
@xiaoxmeng has imported this pull request. If you are a Meta employee, you can view this in D88172777. |
xiaoxmeng
left a comment
There was a problem hiding this 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?
|
The Spark fuzzer failure seems unrelated, do you know why? @rui-mo |

Support legacy date formatter for Spark date_format function.