-
Notifications
You must be signed in to change notification settings - Fork 186
DATE_FORMAT function #764
DATE_FORMAT function #764
Conversation
…rch#522) * Bug fix, support long type for aggregation * change to datetime to JDBC format
* prepare odfe 1.9 * Fix all ES 7.8 compile and build errors * Revert changes as Lombok is working now * Update CustomExternalTestCluster.java * Fix license headers check * Use splitFieldsByMetadata to separate fields when calling SearchHit constructor * More fixes for ODFE 1.9 * Remove todo statement * Add ODFE 1.9.0 release notes
…ticsearch#551) * Revert "Rename release notes to use 4 digit versions (opendistro-for-elasticsearch#547)" This reverts commit 33c6d3e. * Revert "Opendistro Release 1.9.0 (opendistro-for-elasticsearch#532)" This reverts commit 254f2e0. * Revert "Bug fix, support long type for aggregation (opendistro-for-elasticsearch#522)" This reverts commit fb2ed91.
Merge develop to master
…h#549) (opendistro-for-elasticsearch#554) * merge all sql repos * fix test and build workflows * fix workbench and odbc path * fix workbench and odbc path * restructure workbench dir and fix workflows * fix workbench workflow * fix workbench workflow * fix workbench workflow * fix workbench workflow * fix workbench workflow * revert workbench directory structure * fix workbench workflow * fix workbench workflow * fix workbench workflow * fix workbench workflow * update workbench workflow for release * Delete .github/ in sql-workbench directory * Add cypress to sql-workbench * Sync latest ODBC commits * Sync latest workbench commits (will add cypress in separate PR) * Add ignored ODBC libs
* add date and time support * update doc * update doc
…ticsearch#633) Merge develop to master for ODFE 1.9.0.1 release
…stro-for-elasticsearch#638) Merge fixes for github release actions from develop to master
…rch#642) Fix odbc win32 release workflow for master
…-elasticsearch#645) - add null check to avoid crashing if details not initialized
…or-elasticsearch/develop Merge develop branch into master to cut odfe1.10 release
…lasticsearch#701) Merge develop branch into master for od1.10 release
…icsearch#704) Merge workflow fix to master for od1.10 release
…sticsearch#733) Merge develop to master for ODFE 1.10.1.0 release
…arch/sql into lyndon/date-format-function
…/sql into lyndon/date-format-function
…ime-function-week # Conflicts: # core/src/main/java/com/amazon/opendistroforelasticsearch/sql/data/model/ExprStringValue.java # core/src/main/java/com/amazon/opendistroforelasticsearch/sql/expression/DSL.java # core/src/main/java/com/amazon/opendistroforelasticsearch/sql/expression/datetime/DateTimeFunction.java # core/src/main/java/com/amazon/opendistroforelasticsearch/sql/expression/function/BuiltinFunctionName.java # docs/user/dql/functions.rst # integ-test/src/test/java/com/amazon/opendistroforelasticsearch/sql/ppl/DateTimeFunctionIT.java # ppl/src/main/antlr/OpenDistroPPLParser.g4 # sql/src/main/antlr/OpenDistroSQLParser.g4
…into lyndon/date-format-function\
…arch/sql into lyndon/date-format-function [1] Fixing merge conflicts
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.
LGTM!
* @param formatExpr the format ExprValue of String type. | ||
* @return Date formatted using format and returned as a String. | ||
*/ | ||
static ExprValue getFormattedDate(ExprValue dateExpr, ExprValue formatExpr) { |
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.
Not sure the use case. Do you try to do something like this format.replace("%\W", () -> replace).
If so, i recommended to consider the https://docs.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html#appendReplacement(java.lang.StringBuffer,%20java.lang.String)
which provide the more clean code structure.
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 didn't realize I could do this, tahnks for the suggestion! I have updated with this change.
* @param format Incoming format String without mapping completed. | ||
* @return Outgoing format String with mapping completed. | ||
*/ | ||
private static String literalReplace(String format) { |
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.
What is the expected result if the user input the format string which we doesn't support?
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.
Do you mean a format we don't support, such as %z?
According to the documentation for MySQL it should come out as just z, so using the DateTimeFormatter specification, to get a literal out, we wrap in ', so %z => 'z'.
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.
Got it, does it covered in the test cases also?
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.
Yes
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 for the change!
*Issue #710
Description of changes:
Added implementation, unit tests, manual integration tests, and documentation for date_format function.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.