-
Notifications
You must be signed in to change notification settings - Fork 25k
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
SQL: Fix the inconsistent behaviour of ISO_WEEK_YEAR() #68758
Changes from all commits
835ac7b
8c8b01f
110858c
da98724
dc33982
0d74049
4e8689b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,13 +15,13 @@ | |
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.DateDiffProcessor; | ||
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.DatePartProcessor; | ||
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.DateTimeFormatProcessor.Formatter; | ||
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.DateTimeFunction; | ||
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.DateTimeParseProcessor.Parser; | ||
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.DateTimeProcessor; | ||
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.DateTruncProcessor; | ||
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.NamedDateTimeProcessor.NameExtractor; | ||
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.NonIsoDateTimeProcessor.NonIsoDateTimeExtractor; | ||
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.QuarterProcessor; | ||
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.TimeFunction; | ||
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.TimeProcessor; | ||
import org.elasticsearch.xpack.sql.expression.function.scalar.geo.GeoProcessor; | ||
import org.elasticsearch.xpack.sql.expression.function.scalar.geo.StDistanceProcessor; | ||
import org.elasticsearch.xpack.sql.expression.function.scalar.geo.StWkttosqlProcessor; | ||
|
@@ -217,18 +217,36 @@ public static Number sqrt(Number value) { | |
public static Number tan(Number value) { | ||
return MathOperation.TAN.apply(value); | ||
} | ||
|
||
|
||
|
||
// | ||
// Date/Time functions | ||
// | ||
// | ||
@Deprecated | ||
public static Integer dateTimeChrono(Object dateTime, String tzId, String chronoName) { | ||
if (dateTime == null || tzId == null || chronoName == null) { | ||
String extractorName = null; | ||
switch (chronoName) { | ||
case "DAY_OF_WEEK": | ||
extractorName = "ISO_DAY_OF_WEEK"; | ||
break; | ||
case "ALIGNED_WEEK_OF_YEAR": | ||
extractorName = "ISO_WEEK_OF_YEAR"; | ||
break; | ||
default: | ||
extractorName = chronoName; | ||
} | ||
return dateTimeExtract(dateTime, tzId, extractorName); | ||
} | ||
|
||
public static Integer dateTimeExtract(Object dateTime, String tzId, String extractorName) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have a strong preference regarding the method rename however there is an associated cost for it in backwards compatibility. To avoid this, simply keep There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, good catch. It is not just a simple method rename, also the possible values of the last parameter changed (from |
||
if (dateTime == null || tzId == null || extractorName == null) { | ||
return null; | ||
} | ||
if (dateTime instanceof OffsetTime) { | ||
return TimeFunction.dateTimeChrono((OffsetTime) dateTime, tzId, chronoName); | ||
return TimeProcessor.doProcess((OffsetTime) dateTime, tzId, extractorName); | ||
} | ||
return DateTimeFunction.dateTimeChrono(asDateTime(dateTime), tzId, chronoName); | ||
return DateTimeProcessor.doProcess(asDateTime(dateTime), tzId, extractorName); | ||
} | ||
|
||
public static String dayName(Object dateTime, String tzId) { | ||
|
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.
Note to self: "manual" checking the csv specs sometimes pays off.