You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jc...@apache.org on 2019/04/15 16:17:12 UTC

[hive] 01/02: HIVE-21613: Queries with join condition having timestamp or timestamp with local time zone literal throw SemanticException (Jesus Camacho Rodriguez, reviewed by Sankar Hariappan)

This is an automated email from the ASF dual-hosted git repository.

jcamacho pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit d200cb34b99cc24c5a971f3937ba8b407cffcae9
Author: Jesus Camacho Rodriguez <jc...@apache.org>
AuthorDate: Fri Apr 12 20:12:04 2019 -0700

    HIVE-21613: Queries with join condition having timestamp or timestamp with local time zone literal throw SemanticException (Jesus Camacho Rodriguez, reviewed by Sankar Hariappan)
---
 .../test/resources/testconfiguration.properties    |  2 +
 .../hadoop/hive/ql/parse/SemanticAnalyzer.java     |  2 +
 ql/src/test/queries/clientpositive/timestamp_4.q   | 15 ++++++
 ql/src/test/queries/clientpositive/timestamptz_5.q | 16 ++++++
 .../results/clientpositive/llap/timestamp_4.q.out  | 58 ++++++++++++++++++++++
 .../clientpositive/llap/timestamptz_5.q.out        | 57 +++++++++++++++++++++
 6 files changed, 150 insertions(+)

diff --git a/itests/src/test/resources/testconfiguration.properties b/itests/src/test/resources/testconfiguration.properties
index 06b59a7..4a4cca7 100644
--- a/itests/src/test/resources/testconfiguration.properties
+++ b/itests/src/test/resources/testconfiguration.properties
@@ -774,6 +774,8 @@ minillaplocal.query.files=\
   tez_union_multiinsert.q,\
   tez_vector_dynpart_hashjoin_1.q,\
   tez_vector_dynpart_hashjoin_2.q,\
+  timestamp_4.q,\
+  timestamptz_5.q,\
   transitive_not_null.q,\
   truncate_external_force.q,\
   uber_reduce.q,\
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
index 73ae3ba..f89e8f8 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
@@ -2712,6 +2712,8 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
     case HiveParser.KW_TRUE:
     case HiveParser.KW_FALSE:
     case HiveParser.TOK_DATELITERAL:
+    case HiveParser.TOK_TIMESTAMPLITERAL:
+    case HiveParser.TOK_TIMESTAMPLOCALTZLITERAL:
     case HiveParser.TOK_INTERVAL_DAY_LITERAL:
     case HiveParser.TOK_INTERVAL_DAY_TIME:
     case HiveParser.TOK_INTERVAL_DAY_TIME_LITERAL:
diff --git a/ql/src/test/queries/clientpositive/timestamp_4.q b/ql/src/test/queries/clientpositive/timestamp_4.q
new file mode 100644
index 0000000..b7a6dcc
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/timestamp_4.q
@@ -0,0 +1,15 @@
+drop table if exists timestamp_1;
+drop table if exists timestamp_2;
+
+create table timestamp_1 (key int, dd timestamp);
+create table timestamp_2 (key int, dd timestamp);
+
+-- between clause with timestamp literal in join condition
+select d1.key, d2.dd
+  from (select key, dd as start_dd, current_timestamp as end_dd from timestamp_1) d1
+  join timestamp_2 as d2
+    on d1.key = d2.key
+    where d2.dd between start_dd and end_dd;
+
+drop table timestamp_1;
+drop table timestamp_2;
\ No newline at end of file
diff --git a/ql/src/test/queries/clientpositive/timestamptz_5.q b/ql/src/test/queries/clientpositive/timestamptz_5.q
new file mode 100644
index 0000000..d1e15ee
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/timestamptz_5.q
@@ -0,0 +1,16 @@
+set hive.cbo.enable=false;
+
+drop table if exists timestamplocaltz_n1;
+drop table if exists timestamplocaltz_n2;
+
+create table timestamplocaltz_n1 (key int, dd timestamp with local time zone);
+create table timestamplocaltz_n2 (key int, dd timestamp with local time zone);
+
+-- between clause with timestamp literal in join condition
+select d1.key, d2.dd
+  from (select key, dd as start_dd, current_timestamp as end_dd from timestamplocaltz_n1) d1
+  join timestamplocaltz_n2 as d2
+    on d1.key = d2.key or d2.dd between timestamplocaltz '2010-04-01 00:00:00 America/Los_Angeles' and timestamplocaltz '2010-04-02 00:00:00 America/Los_Angeles';
+
+drop table timestamplocaltz_n1;
+drop table timestamplocaltz_n2;
\ No newline at end of file
diff --git a/ql/src/test/results/clientpositive/llap/timestamp_4.q.out b/ql/src/test/results/clientpositive/llap/timestamp_4.q.out
new file mode 100644
index 0000000..54864de
--- /dev/null
+++ b/ql/src/test/results/clientpositive/llap/timestamp_4.q.out
@@ -0,0 +1,58 @@
+PREHOOK: query: drop table if exists timestamp_1
+PREHOOK: type: DROPTABLE
+POSTHOOK: query: drop table if exists timestamp_1
+POSTHOOK: type: DROPTABLE
+PREHOOK: query: drop table if exists timestamp_2
+PREHOOK: type: DROPTABLE
+POSTHOOK: query: drop table if exists timestamp_2
+POSTHOOK: type: DROPTABLE
+PREHOOK: query: create table timestamp_1 (key int, dd timestamp)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@timestamp_1
+POSTHOOK: query: create table timestamp_1 (key int, dd timestamp)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@timestamp_1
+PREHOOK: query: create table timestamp_2 (key int, dd timestamp)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@timestamp_2
+POSTHOOK: query: create table timestamp_2 (key int, dd timestamp)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@timestamp_2
+PREHOOK: query: select d1.key, d2.dd
+  from (select key, dd as start_dd, current_timestamp as end_dd from timestamp_1) d1
+  join timestamp_2 as d2
+    on d1.key = d2.key
+    where d2.dd between start_dd and end_dd
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+PREHOOK: Input: default@timestamp_2
+#### A masked pattern was here ####
+POSTHOOK: query: select d1.key, d2.dd
+  from (select key, dd as start_dd, current_timestamp as end_dd from timestamp_1) d1
+  join timestamp_2 as d2
+    on d1.key = d2.key
+    where d2.dd between start_dd and end_dd
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+POSTHOOK: Input: default@timestamp_2
+#### A masked pattern was here ####
+PREHOOK: query: drop table timestamp_1
+PREHOOK: type: DROPTABLE
+PREHOOK: Input: default@timestamp_1
+PREHOOK: Output: default@timestamp_1
+POSTHOOK: query: drop table timestamp_1
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Input: default@timestamp_1
+POSTHOOK: Output: default@timestamp_1
+PREHOOK: query: drop table timestamp_2
+PREHOOK: type: DROPTABLE
+PREHOOK: Input: default@timestamp_2
+PREHOOK: Output: default@timestamp_2
+POSTHOOK: query: drop table timestamp_2
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Input: default@timestamp_2
+POSTHOOK: Output: default@timestamp_2
diff --git a/ql/src/test/results/clientpositive/llap/timestamptz_5.q.out b/ql/src/test/results/clientpositive/llap/timestamptz_5.q.out
new file mode 100644
index 0000000..ca5ebe5
--- /dev/null
+++ b/ql/src/test/results/clientpositive/llap/timestamptz_5.q.out
@@ -0,0 +1,57 @@
+PREHOOK: query: drop table if exists timestamplocaltz_n1
+PREHOOK: type: DROPTABLE
+POSTHOOK: query: drop table if exists timestamplocaltz_n1
+POSTHOOK: type: DROPTABLE
+PREHOOK: query: drop table if exists timestamplocaltz_n2
+PREHOOK: type: DROPTABLE
+POSTHOOK: query: drop table if exists timestamplocaltz_n2
+POSTHOOK: type: DROPTABLE
+PREHOOK: query: create table timestamplocaltz_n1 (key int, dd timestamp with local time zone)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@timestamplocaltz_n1
+POSTHOOK: query: create table timestamplocaltz_n1 (key int, dd timestamp with local time zone)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@timestamplocaltz_n1
+PREHOOK: query: create table timestamplocaltz_n2 (key int, dd timestamp with local time zone)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@timestamplocaltz_n2
+POSTHOOK: query: create table timestamplocaltz_n2 (key int, dd timestamp with local time zone)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@timestamplocaltz_n2
+Warning: Shuffle Join MERGEJOIN[8][tables = [d1, d2]] in Stage 'Reducer 2' is a cross product
+PREHOOK: query: select d1.key, d2.dd
+  from (select key, dd as start_dd, current_timestamp as end_dd from timestamplocaltz_n1) d1
+  join timestamplocaltz_n2 as d2
+    on d1.key = d2.key or d2.dd between timestamplocaltz '2010-04-01 00:00:00 America/Los_Angeles' and timestamplocaltz '2010-04-02 00:00:00 America/Los_Angeles'
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamplocaltz_n1
+PREHOOK: Input: default@timestamplocaltz_n2
+#### A masked pattern was here ####
+POSTHOOK: query: select d1.key, d2.dd
+  from (select key, dd as start_dd, current_timestamp as end_dd from timestamplocaltz_n1) d1
+  join timestamplocaltz_n2 as d2
+    on d1.key = d2.key or d2.dd between timestamplocaltz '2010-04-01 00:00:00 America/Los_Angeles' and timestamplocaltz '2010-04-02 00:00:00 America/Los_Angeles'
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamplocaltz_n1
+POSTHOOK: Input: default@timestamplocaltz_n2
+#### A masked pattern was here ####
+PREHOOK: query: drop table timestamplocaltz_n1
+PREHOOK: type: DROPTABLE
+PREHOOK: Input: default@timestamplocaltz_n1
+PREHOOK: Output: default@timestamplocaltz_n1
+POSTHOOK: query: drop table timestamplocaltz_n1
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Input: default@timestamplocaltz_n1
+POSTHOOK: Output: default@timestamplocaltz_n1
+PREHOOK: query: drop table timestamplocaltz_n2
+PREHOOK: type: DROPTABLE
+PREHOOK: Input: default@timestamplocaltz_n2
+PREHOOK: Output: default@timestamplocaltz_n2
+POSTHOOK: query: drop table timestamplocaltz_n2
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Input: default@timestamplocaltz_n2
+POSTHOOK: Output: default@timestamplocaltz_n2