This is an automated email from the ASF dual-hosted git repository.
dzamo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git
The following commit(s) were added to refs/heads/master by this push:
new acac986 DRILL-8143: Error querying json with $date field (#2469)
acac986 is described below
commit acac9863e5ca062a6204ba5f9071a4f1201c0229
Author: Anton Gozhiy <[email protected]>
AuthorDate: Mon Feb 21 16:07:38 2022 +0200
DRILL-8143: Error querying json with $date field (#2469)
---
distribution/src/main/resources/sqlline.bat | 2 +-
.../org/apache/drill/exec/vector/complex/fn/VectorOutput.java | 11 +++++++++--
exec/java-exec/src/test/resources/jsoninput/input2.json | 4 ++--
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/distribution/src/main/resources/sqlline.bat
b/distribution/src/main/resources/sqlline.bat
index edad53b..ac819bd 100644
--- a/distribution/src/main/resources/sqlline.bat
+++ b/distribution/src/main/resources/sqlline.bat
@@ -203,7 +203,7 @@ if errorlevel 1 (
rem allow reflective access on Java 9+
set DRILL_SHELL_JAVA_OPTS=!DRILL_SHELL_JAVA_OPTS! ^
--add-opens java.base/java.lang=ALL-UNNAMED ^
- --add-opens=java.base/java.util=ALL-UNNAMED
+ --add-opens=java.base/java.util=ALL-UNNAMED ^
--add-opens java.base/sun.nio.ch=ALL-UNNAMED ^
--add-opens java.base/java.net=ALL-UNNAMED ^
--add-opens java.base/java.nio=ALL-UNNAMED ^
diff --git
a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/fn/VectorOutput.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/fn/VectorOutput.java
index 7a22fb1..4493518 100644
---
a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/fn/VectorOutput.java
+++
b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/fn/VectorOutput.java
@@ -25,6 +25,8 @@ import java.time.OffsetDateTime;
import java.time.OffsetTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeFormatterBuilder;
import org.apache.drill.common.exceptions.UserException;
import org.apache.drill.exec.expr.fn.impl.DateUtility;
@@ -72,6 +74,11 @@ abstract class VectorOutput {
protected final WorkingBuffer work;
protected JsonParser parser;
+ protected DateTimeFormatter isoDateTimeFormatter = new
DateTimeFormatterBuilder().append(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
+ .optionalStart().appendOffset("+HH:MM", "+00:00").optionalEnd()
+ .optionalStart().appendOffset("+HHMM", "+0000").optionalEnd()
+ .optionalStart().appendOffset("+HH", "Z").optionalEnd()
+ .toFormatter();
public VectorOutput(WorkingBuffer work){
this.work = work;
@@ -254,7 +261,7 @@ abstract class VectorOutput {
// See the mongo specs and the Drill handler (in new JSON loader) :
// 1. https://docs.mongodb.com/manual/reference/mongodb-extended-json
// 2.
org.apache.drill.exec.store.easy.json.values.UtcTimestampValueListener
- Instant instant = Instant.parse(parser.getValueAsString());
+ Instant instant =
isoDateTimeFormatter.parse(parser.getValueAsString(), Instant::from);
long offset =
ZoneId.systemDefault().getRules().getOffset(instant).getTotalSeconds() * 1000;
ts.writeTimeStamp(instant.toEpochMilli() + offset);
break;
@@ -361,7 +368,7 @@ abstract class VectorOutput {
// See the mongo specs and the Drill handler (in new JSON loader) :
// 1. https://docs.mongodb.com/manual/reference/mongodb-extended-json
// 2.
org.apache.drill.exec.store.easy.json.values.UtcTimestampValueListener
- Instant instant = Instant.parse(parser.getValueAsString());
+ Instant instant =
isoDateTimeFormatter.parse(parser.getValueAsString(), Instant::from);
long offset =
ZoneId.systemDefault().getRules().getOffset(instant).getTotalSeconds() * 1000;
ts.writeTimeStamp(instant.toEpochMilli() + offset);
break;
diff --git a/exec/java-exec/src/test/resources/jsoninput/input2.json
b/exec/java-exec/src/test/resources/jsoninput/input2.json
index e95442e..06cd38b 100644
--- a/exec/java-exec/src/test/resources/jsoninput/input2.json
+++ b/exec/java-exec/src/test/resources/jsoninput/input2.json
@@ -29,7 +29,7 @@
"l": [4,2],
"rl": [ [2,1], [4,6] ],
"date" : {
- "$date" : "2019-09-30T20:47:43.10Z"
+ "$date" : "2019-09-30T20:47:43.10+05"
}
}
{ "integer" : 6005,
@@ -44,6 +44,6 @@
"l": [4,2],
"rl": [ [2,1], [4,6] ],
"date" : {
- "$date" : "2019-09-30T20:47:43.1Z"
+ "$date" : "2019-09-30T20:47:43.1+05:30"
}
}