You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2021/07/06 12:08:38 UTC

[GitHub] [hive] adesh-rao opened a new pull request #2447: HIVE-25299: Incorporate timezone while converting timestamp to numeric data types

adesh-rao opened a new pull request #2447:
URL: https://github.com/apache/hive/pull/2447


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] adesh-rao commented on pull request #2447: HIVE-25299: Incorporate timezone while converting timestamp to numeric data types

Posted by GitBox <gi...@apache.org>.
adesh-rao commented on pull request #2447:
URL: https://github.com/apache/hive/pull/2447#issuecomment-874891754


   The jira was just to fix the timestamp conversion. Also, UDFToInteger seems to be used for acid related code too (contains a method to convert recordidentifier to int). 
   
   Instead of doing refactoring and fixing timestamp conversion in the same jira, We can create a followup jira to refactor the UDF. I will create that create and attach the link here. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] adesh-rao commented on a change in pull request #2447: HIVE-25299: Incorporate timezone while converting timestamp to numeric data types

Posted by GitBox <gi...@apache.org>.
adesh-rao commented on a change in pull request #2447:
URL: https://github.com/apache/hive/pull/2447#discussion_r665937887



##########
File path: ql/src/test/results/clientpositive/llap/timestamp_1.q.out
##########
@@ -257,7 +329,7 @@ POSTHOOK: query: select cast(t as double) from timestamp_1 limit 1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@timestamp_1
 #### A masked pattern was here ####
-1.2938436611E9
+1.293843661E9

Review comment:
       Yes the precision value is same.
   
   `beeline -u "jdbc:hive2://zk0-nikhil.ae4yqb3genuuvaozdfax4l12ud.dx.internal.cloudapp.net:2181,zk2-nikhil.ae4yqb3genuuvaozdfax4l12ud.dx.internal.cloudapp.net:2181,zk4-nikhil.ae4yqb3genuuvaozdfax4l12ud.dx.internal.cloudapp.net:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2"
   
   Connecting to jdbc:hive2://zk0-nikhil.ae4yqb3genuuvaozdfax4l12ud.dx.internal.cloudapp.net:2181,zk2-nikhil.ae4yqb3genuuvaozdfax4l12ud.dx.internal.cloudapp.net:2181,zk4-nikhil.ae4yqb3genuuvaozdfax4l12ud.dx.internal.cloudapp.net:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
   
   Connected to: Apache Hive (version 1.2.1000.2.6.5.3033-1)
   
   Driver: Hive JDBC (version 1.2.1000.2.6.5.3033-1)
   
   Transaction isolation: TRANSACTION_REPEATABLE_READ
   
   Beeline version 1.2.1000.2.6.5.3033-1 by Apache Hive
   
   0: jdbc:hive2://zk0-nikhil.ae4yqb3genuuvaozdf> select cast(cast('2011-01-01 01:01:01' as timestamp) as double) ;;
   
   +----------------+--+
   |      _c0       |
   +----------------+--+
   | 1.293843661E9  |
   +----------------+--+
   
   1 row selected (0.452 seconds)
   
   0: jdbc:hive2://zk0-nikhil.ae4yqb3genuuvaozdf> select cast(cast('2011-01-01 01:01:01' as timestamp) as float) ;;
   
   +---------------+--+
   |      _c0      |
   +---------------+--+
   | 1.29384371E9  |
   +---------------+--+
   
   1 row selected (0.81 seconds)
   `




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] sankarh commented on pull request #2447: HIVE-25299: Incorporate timezone while converting timestamp to numeric data types

Posted by GitBox <gi...@apache.org>.
sankarh commented on pull request #2447:
URL: https://github.com/apache/hive/pull/2447#issuecomment-874992670


   @adesh-rao Could you pls add unit tests?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] sankarh commented on a change in pull request #2447: HIVE-25299: Incorporate timezone while converting timestamp to numeric data types

Posted by GitBox <gi...@apache.org>.
sankarh commented on a change in pull request #2447:
URL: https://github.com/apache/hive/pull/2447#discussion_r665477114



##########
File path: common/src/java/org/apache/hadoop/hive/common/type/TimestampTZUtil.java
##########
@@ -186,4 +186,8 @@ public static Timestamp convertTimestampToZone(Timestamp ts, ZoneId fromZone, Zo
     return Timestamp.ofEpochSecond(localDateTimeAtToZone.toEpochSecond(ZoneOffset.UTC),
         localDateTimeAtToZone.getNano());
   }
+
+  public static double convertTimestampTZToDouble(TimestampTZ timestampTZ) {
+    return timestampTZ.getEpochSecond() + timestampTZ.getNanos() / 1000000000;

Review comment:
       Can use DateUtils.NANOS_PER_SEC instead of hardcoding.

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/udf/UDFToByte.java
##########
@@ -211,7 +217,10 @@ public ByteWritable evaluate(TimestampWritableV2 i) {
     if (i == null) {
       return null;
     } else {
-      final long longValue = i.getSeconds();
+      ZoneId zone = SessionState.get() == null ?
+        new HiveConf().getLocalTimeZone() : SessionState.get().getConf().getLocalTimeZone();
+      TimestampTZ timestamp = TimestampTZUtil.convert(i.getTimestamp(), zone);

Review comment:
       Duplicate code. Can write an utility method in TimestampTZUtil that takes timestamp as input, convert and return TimestampTZ.

##########
File path: ql/src/test/results/clientpositive/llap/timestamp_1.q.out
##########
@@ -257,7 +329,7 @@ POSTHOOK: query: select cast(t as double) from timestamp_1 limit 1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@timestamp_1
 #### A masked pattern was here ####
-1.2938436611E9
+1.293843661E9

Review comment:
       Does this precision values match with Hive 1.2?

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/udf/UDFToBoolean.java
##########
@@ -213,7 +219,10 @@ public BooleanWritable evaluate(TimestampWritableV2 i) {
     if (i == null) {
       return null;
     } else {
-      booleanWritable.set(i.getSeconds() != 0 || i.getNanos() != 0);
+      ZoneId zone = SessionState.get() == null ?
+        new HiveConf().getLocalTimeZone() : SessionState.get().getConf().getLocalTimeZone();
+      TimestampTZ timestamp = TimestampTZUtil.convert(i.getTimestamp(), zone);
+      booleanWritable.set(timestamp.getEpochSecond() != 0 || timestamp.getNanos() != 0);

Review comment:
       Nit: Use () around each conditions.

##########
File path: ql/src/test/queries/clientpositive/timestamp_2.q
##########
@@ -17,6 +17,19 @@ select cast(t as float) from timestamp_2 limit 1;
 select cast(t as double) from timestamp_2 limit 1;
 select cast(t as string) from timestamp_2 limit 1;
 
+set hive.local.time.zone=Asia/Bangkok;
+
+select cast(t as boolean) from timestamp_2 limit 1;

Review comment:
       I don't see any diff between timestamp_1 and timestamp_2 testcases. Is it duplicate?

##########
File path: ql/src/test/results/clientpositive/llap/timestamp_1.q.out
##########
@@ -101,6 +101,78 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@timestamp_1
 #### A masked pattern was here ####
 2011-01-01 01:01:01
+PREHOOK: query: select cast(t as boolean) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as boolean) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+true
+PREHOOK: query: select cast(t as tinyint) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as tinyint) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+NULL
+PREHOOK: query: select cast(t as smallint) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as smallint) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+NULL
+PREHOOK: query: select cast(t as int) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as int) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+1293843661
+PREHOOK: query: select cast(t as bigint) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as bigint) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+1293818461
+PREHOOK: query: select cast(t as float) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as float) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+1.2938185E9

Review comment:
       Output of cast(float) and cast(double) mismatch with UTC one. 

##########
File path: ql/src/test/results/clientpositive/llap/timestamp_1.q.out
##########
@@ -101,6 +101,78 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@timestamp_1
 #### A masked pattern was here ####
 2011-01-01 01:01:01
+PREHOOK: query: select cast(t as boolean) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as boolean) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+true
+PREHOOK: query: select cast(t as tinyint) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as tinyint) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+NULL
+PREHOOK: query: select cast(t as smallint) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as smallint) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+NULL
+PREHOOK: query: select cast(t as int) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as int) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+1293843661
+PREHOOK: query: select cast(t as bigint) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as bigint) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+1293818461

Review comment:
       Why the output mismatch with cast(int)?

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/udf/UDFToBoolean.java
##########
@@ -213,7 +219,10 @@ public BooleanWritable evaluate(TimestampWritableV2 i) {
     if (i == null) {
       return null;
     } else {
-      booleanWritable.set(i.getSeconds() != 0 || i.getNanos() != 0);
+      ZoneId zone = SessionState.get() == null ?

Review comment:
       nit: Use () around condition.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] adesh-rao commented on a change in pull request #2447: HIVE-25299: Incorporate timezone while converting timestamp to numeric data types

Posted by GitBox <gi...@apache.org>.
adesh-rao commented on a change in pull request #2447:
URL: https://github.com/apache/hive/pull/2447#discussion_r665934575



##########
File path: ql/src/test/results/clientpositive/llap/timestamp_1.q.out
##########
@@ -101,6 +101,78 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@timestamp_1
 #### A masked pattern was here ####
 2011-01-01 01:01:01
+PREHOOK: query: select cast(t as boolean) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as boolean) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+true
+PREHOOK: query: select cast(t as tinyint) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as tinyint) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+NULL
+PREHOOK: query: select cast(t as smallint) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as smallint) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+NULL
+PREHOOK: query: select cast(t as int) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as int) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+1293843661
+PREHOOK: query: select cast(t as bigint) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as bigint) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+1293818461
+PREHOOK: query: select cast(t as float) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as float) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+1.2938185E9

Review comment:
       This is coming because of timezone difference between UTC and Asia/Bangkok (+7hrs). 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] sankarh merged pull request #2447: HIVE-25299: Incorporate timezone while converting timestamp to numeric data types

Posted by GitBox <gi...@apache.org>.
sankarh merged pull request #2447:
URL: https://github.com/apache/hive/pull/2447


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] adesh-rao commented on a change in pull request #2447: HIVE-25299: Incorporate timezone while converting timestamp to numeric data types

Posted by GitBox <gi...@apache.org>.
adesh-rao commented on a change in pull request #2447:
URL: https://github.com/apache/hive/pull/2447#discussion_r665925432



##########
File path: ql/src/test/queries/clientpositive/timestamp_2.q
##########
@@ -17,6 +17,19 @@ select cast(t as float) from timestamp_2 limit 1;
 select cast(t as double) from timestamp_2 limit 1;
 select cast(t as string) from timestamp_2 limit 1;
 
+set hive.local.time.zone=Asia/Bangkok;
+
+select cast(t as boolean) from timestamp_2 limit 1;

Review comment:
       The difference is between serde of table and the insertion data format.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] adesh-rao commented on a change in pull request #2447: HIVE-25299: Incorporate timezone while converting timestamp to numeric data types

Posted by GitBox <gi...@apache.org>.
adesh-rao commented on a change in pull request #2447:
URL: https://github.com/apache/hive/pull/2447#discussion_r665921335



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/udf/UDFToBoolean.java
##########
@@ -213,7 +219,10 @@ public BooleanWritable evaluate(TimestampWritableV2 i) {
     if (i == null) {
       return null;
     } else {
-      booleanWritable.set(i.getSeconds() != 0 || i.getNanos() != 0);
+      ZoneId zone = SessionState.get() == null ?

Review comment:
       Done.

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/udf/UDFToBoolean.java
##########
@@ -213,7 +219,10 @@ public BooleanWritable evaluate(TimestampWritableV2 i) {
     if (i == null) {
       return null;
     } else {
-      booleanWritable.set(i.getSeconds() != 0 || i.getNanos() != 0);
+      ZoneId zone = SessionState.get() == null ?
+        new HiveConf().getLocalTimeZone() : SessionState.get().getConf().getLocalTimeZone();
+      TimestampTZ timestamp = TimestampTZUtil.convert(i.getTimestamp(), zone);
+      booleanWritable.set(timestamp.getEpochSecond() != 0 || timestamp.getNanos() != 0);

Review comment:
       Done.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] adesh-rao commented on a change in pull request #2447: HIVE-25299: Incorporate timezone while converting timestamp to numeric data types

Posted by GitBox <gi...@apache.org>.
adesh-rao commented on a change in pull request #2447:
URL: https://github.com/apache/hive/pull/2447#discussion_r665922357



##########
File path: common/src/java/org/apache/hadoop/hive/common/type/TimestampTZUtil.java
##########
@@ -186,4 +186,8 @@ public static Timestamp convertTimestampToZone(Timestamp ts, ZoneId fromZone, Zo
     return Timestamp.ofEpochSecond(localDateTimeAtToZone.toEpochSecond(ZoneOffset.UTC),
         localDateTimeAtToZone.getNano());
   }
+
+  public static double convertTimestampTZToDouble(TimestampTZ timestampTZ) {
+    return timestampTZ.getEpochSecond() + timestampTZ.getNanos() / 1000000000;

Review comment:
       Done.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] adesh-rao commented on a change in pull request #2447: HIVE-25299: Incorporate timezone while converting timestamp to numeric data types

Posted by GitBox <gi...@apache.org>.
adesh-rao commented on a change in pull request #2447:
URL: https://github.com/apache/hive/pull/2447#discussion_r665937887



##########
File path: ql/src/test/results/clientpositive/llap/timestamp_1.q.out
##########
@@ -257,7 +329,7 @@ POSTHOOK: query: select cast(t as double) from timestamp_1 limit 1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@timestamp_1
 #### A masked pattern was here ####
-1.2938436611E9
+1.293843661E9

Review comment:
       Yes the precision value is same.
   
   `beeline -u "jdbc:hive2://zk0-nikhil.ae4yqb3genuuvaozdfax4l12ud.dx.internal.cloudapp.net:2181,zk2-nikhil.ae4yqb3genuuvaozdfax4l12ud.dx.internal.cloudapp.net:2181,zk4-nikhil.ae4yqb3genuuvaozdfax4l12ud.dx.internal.cloudapp.net:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2"
   select cast(cast('2011-01-01 01:01:01' as timestamp) as double) ;;
   Connecting to jdbc:hive2://zk0-nikhil.ae4yqb3genuuvaozdfax4l12ud.dx.internal.cloudapp.net:2181,zk2-nikhil.ae4yqb3genuuvaozdfax4l12ud.dx.internal.cloudapp.net:2181,zk4-nikhil.ae4yqb3genuuvaozdfax4l12ud.dx.internal.cloudapp.net:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
   Connected to: Apache Hive (version 1.2.1000.2.6.5.3033-1)
   Driver: Hive JDBC (version 1.2.1000.2.6.5.3033-1)
   Transaction isolation: TRANSACTION_REPEATABLE_READ
   Beeline version 1.2.1000.2.6.5.3033-1 by Apache Hive
   0: jdbc:hive2://zk0-nikhil.ae4yqb3genuuvaozdf> select cast(cast('2011-01-01 01:01:01' as timestamp) as double) ;;
   +----------------+--+
   |      _c0       |
   +----------------+--+
   | 1.293843661E9  |
   +----------------+--+
   1 row selected (0.452 seconds)
   0: jdbc:hive2://zk0-nikhil.ae4yqb3genuuvaozdf> select cast(cast('2011-01-01 01:01:01' as timestamp) as float) ;;
   +---------------+--+
   |      _c0      |
   +---------------+--+
   | 1.29384371E9  |
   +---------------+--+
   1 row selected (0.81 seconds)
   0: jdbc:hive2://zk0-nikhil.ae4yqb3genuuvaozdf>`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] adesh-rao commented on a change in pull request #2447: HIVE-25299: Incorporate timezone while converting timestamp to numeric data types

Posted by GitBox <gi...@apache.org>.
adesh-rao commented on a change in pull request #2447:
URL: https://github.com/apache/hive/pull/2447#discussion_r665922243



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/udf/UDFToByte.java
##########
@@ -211,7 +217,10 @@ public ByteWritable evaluate(TimestampWritableV2 i) {
     if (i == null) {
       return null;
     } else {
-      final long longValue = i.getSeconds();
+      ZoneId zone = SessionState.get() == null ?
+        new HiveConf().getLocalTimeZone() : SessionState.get().getConf().getLocalTimeZone();
+      TimestampTZ timestamp = TimestampTZUtil.convert(i.getTimestamp(), zone);

Review comment:
       Can't be done in TimestampTZUtil (it will create a circular dependency in common/exec modules). Instead create a new UDFUtils.java for the same.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] ashish-kumar-sharma commented on pull request #2447: HIVE-25299: Incorporate timezone while converting timestamp to numeric data types

Posted by GitBox <gi...@apache.org>.
ashish-kumar-sharma commented on pull request #2447:
URL: https://github.com/apache/hive/pull/2447#issuecomment-874727428


   @adesh-rao  Please migrate all this UDF to genericUDF and use timestamp convertor instead of adding timezone related change in each one. As timestamp convertor already have everything required for timezone


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] adesh-rao commented on a change in pull request #2447: HIVE-25299: Incorporate timezone while converting timestamp to numeric data types

Posted by GitBox <gi...@apache.org>.
adesh-rao commented on a change in pull request #2447:
URL: https://github.com/apache/hive/pull/2447#discussion_r665925612



##########
File path: ql/src/test/results/clientpositive/llap/timestamp_1.q.out
##########
@@ -101,6 +101,78 @@ POSTHOOK: type: QUERY
 POSTHOOK: Input: default@timestamp_1
 #### A masked pattern was here ####
 2011-01-01 01:01:01
+PREHOOK: query: select cast(t as boolean) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as boolean) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+true
+PREHOOK: query: select cast(t as tinyint) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as tinyint) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+NULL
+PREHOOK: query: select cast(t as smallint) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as smallint) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+NULL
+PREHOOK: query: select cast(t as int) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as int) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+1293843661
+PREHOOK: query: select cast(t as bigint) from timestamp_1 limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+POSTHOOK: query: select cast(t as bigint) from timestamp_1 limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@timestamp_1
+#### A masked pattern was here ####
+1293818461

Review comment:
       Fixed the output. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] adesh-rao commented on pull request #2447: HIVE-25299: Incorporate timezone while converting timestamp to numeric data types

Posted by GitBox <gi...@apache.org>.
adesh-rao commented on pull request #2447:
URL: https://github.com/apache/hive/pull/2447#issuecomment-875438800


   @sankarh added/modified qtests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org