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: protocol returns ISO 8601 String formatted dates instead of Long for JDBC/ODBC requests #36800
Conversation
of JDBC/ODBC, to ISO 8601 with millis String.
Pinging @elastic/es-search |
@elasticmachine run default distro tests |
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
@@ -20,6 +23,8 @@ | |||
public static final String SQL_TRACE = "org.elasticsearch.xpack.sql:TRACE"; | |||
|
|||
public static final String JDBC_TIMEZONE = "timezone"; | |||
|
|||
public static ZoneId UTC = ZoneId.of("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.
Any reason why org.es.xpack.sql.util.DateUtils
is not used instead?
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 is not visible in the jdbc
project.
import static java.time.temporal.ChronoField.MINUTE_OF_HOUR; | ||
import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; | ||
|
||
final class DateUtils { |
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.
Rename this to JdbcDateUtils to avoid name clashes with the class in the server.
Also add a comment on why this class is here (lack of visibility) since several things from there can be found here.
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.
+1
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
import static java.time.temporal.ChronoField.MINUTE_OF_HOUR; | ||
import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; | ||
|
||
final class DateUtils { |
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.
+1
if (val == null) { | ||
return null; | ||
} | ||
return DateUtils.asDateTimeField(val, DateUtils::asMillisSinceEpoch, (longValue) -> longValue); |
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.
just FYI, you can use Function.identity()
for t->t cases
run the gradle build tests 1 |
1 similar comment
run the gradle build tests 1 |
This PR changes the protocol for JDBC/ODBC requests in case of date columns, returning their values as
String
forZonedDateTime
type of date fields. This changes the current behavior of returninglong
values representing UTC millis since epoch.There are still some situations (Histograms) where the returned value is not a
ZonedDateTime
instance, but aLong
representing UTC millis since epoch. For those cases, the behavior remained unchanged.This addresses #36756.