TRAFODION-3115 Support nanosec precision for Timestamp/Interval datatypes
Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/84d76f4d Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/84d76f4d Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/84d76f4d Branch: refs/heads/master Commit: 84d76f4d3203b9e51803851713bfaeda4112e0b3 Parents: e3af7d9 Author: Anoop Sharma <[email protected]> Authored: Wed Jun 20 21:19:41 2018 +0000 Committer: Anoop Sharma <[email protected]> Committed: Wed Jun 20 21:19:41 2018 +0000 ---------------------------------------------------------------------- .../trafodion/jdbc/t4/InterfaceResultSet.java | 1 - core/sql/common/IntervalType.cpp | 5 ++--- core/sql/parser/StmtDDLMisc.cpp | 10 ---------- core/sql/regress/compGeneral/EXPECTED071 | 4 ++-- core/sql/regress/executor/EXPECTED022.SB | 20 +++++++++++++++----- core/sql/regress/executor/TEST022 | 11 ++++++++--- core/sql/regress/udr/TEST100 | 6 +++--- 7 files changed, 30 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafodion/blob/84d76f4d/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java ---------------------------------------------------------------------- diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java index 2da8276..972c81b 100644 --- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java +++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java @@ -253,7 +253,6 @@ class InterfaceResultSet { retObj = Date.valueOf(tmpStr); break; case SQLDTCODE_TIMESTAMP: - System.out.println("tmpStr = " + tmpStr); retObj = Timestamp.valueOf(tmpStr); break; case SQLDTCODE_TIME: http://git-wip-us.apache.org/repos/asf/trafodion/blob/84d76f4d/core/sql/common/IntervalType.cpp ---------------------------------------------------------------------- diff --git a/core/sql/common/IntervalType.cpp b/core/sql/common/IntervalType.cpp index 778505e..74d6d7a 100644 --- a/core/sql/common/IntervalType.cpp +++ b/core/sql/common/IntervalType.cpp @@ -298,12 +298,11 @@ Lng32 IntervalType::getStorageSize(rec_datetime_field startField, rec_datetime_field endField, UInt32 fractionPrecision) { - Lng32 prec = getPrecision(startField, + Lng32 size = getBinaryStorageSize(getPrecision(startField, leadingPrecision, endField, - fractionPrecision); + fractionPrecision)); - Lng32 size = getBinaryStorageSize(prec); // interval datatypes are stored as 2(smallint),4(int) or 8(largeint) bytes. // If size is tinyint size based on precision, change it to smallint size. http://git-wip-us.apache.org/repos/asf/trafodion/blob/84d76f4d/core/sql/parser/StmtDDLMisc.cpp ---------------------------------------------------------------------- diff --git a/core/sql/parser/StmtDDLMisc.cpp b/core/sql/parser/StmtDDLMisc.cpp index b41c888..c98984b 100644 --- a/core/sql/parser/StmtDDLMisc.cpp +++ b/core/sql/parser/StmtDDLMisc.cpp @@ -110,16 +110,6 @@ StmtDDLCleanupObjects::bindNode(BindWA * pBindWA) // remember the original table name specified by user origTableQualName_ = *tableQualName_; - if ((type_ == HIVE_TABLE_) || - (type_ == HIVE_VIEW_)) - { - // add hive catalog/schema names if not specified - if (tableQualName_->getCatalogName().isNull()) - tableQualName_->setCatalogName(HIVE_SYSTEM_CATALOG); - if (tableQualName_->getSchemaName().isNull()) - tableQualName_->setCatalogName(HIVE_SYSTEM_SCHEMA); - } - if (applyDefaultsAndValidateObject(pBindWA, tableQualName_)) { pBindWA->setErrStatus(); http://git-wip-us.apache.org/repos/asf/trafodion/blob/84d76f4d/core/sql/regress/compGeneral/EXPECTED071 ---------------------------------------------------------------------- diff --git a/core/sql/regress/compGeneral/EXPECTED071 b/core/sql/regress/compGeneral/EXPECTED071 index f87f526..8a5774d 100644 --- a/core/sql/regress/compGeneral/EXPECTED071 +++ b/core/sql/regress/compGeneral/EXPECTED071 @@ -1020,7 +1020,7 @@ TRAFODION_SCAN MTDN1 OPERATOR TNAME BKEY EKEY ------------------------------ ------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -TRAFODION_SCAN MTDN3 begin_key: (_SALT_ = <min>), (_DIVISION_1_ = DATE_PART('YEARQUARTER',%(2009-12-06 12:13:14))), (_DIVISION_2_ = 'ab '), (_DIVISION_3_ = cast((cast(((cast((cast(((cast(%(2099-01-06 12:13:14.555555)) - cast((cast(dayofweek(%(2099-01-06 12:13:14.555555))) - cast(1)))) - (cast(1900-01-01) - cast((cast(dayofweek(1900-01-01)) - cast(1)))))) * cast(10))) / cast(7)) / cast(10))) / cast(001)))), (_DIVISION_4_ = 'ab'), (_DIVISION_5_ = <min>), (PC1 = %(2009-12-06 12:13:14)), (PC2 = %(2099-01-06 12:13:14.555555)), (PC3 = 'ab'), (PC4 = <min>) end_key: (_SALT_ = <max>), (_DIVISION_1_ = DATE_PART('YEARQUARTER',%(2009-12-06 12:13:14))), (_DIVISION_2_ = 'abcf'), (_DIVISION_3_ = cast((cast(((cast((cast(((cast(%(2099-01-06 12:13:14.555555)) - cast((cast(dayofweek(%(2099-01-06 12:13:14.555555))) - cast(1)))) - (cast(1900-01-01) - cast((cast(dayo fweek(1900-01-01)) - cast(1)))))) * cast(10))) / cast(7)) / cast(10))) / cast(001)))), (_DIVISION_4_ = 'ab'), (_DIVISION_5_ = <max>), (PC1 = %(2009-12-06 12:13:14)), (PC2 = %(2099-01-06 12:13:14.555555)), (PC3 = 'abcf'), (PC4 = <max>) +TRAFODION_SCAN MTDN3 begin_key: (_SALT_ = <min>), (_DIVISION_1_ = DATE_PART('YEARQUARTER',%(2009-12-06 12:13:14))), (_DIVISION_2_ = 'ab '), (_DIVISION_3_ = cast((cast(((cast((cast(cast(((cast(%(2099-01-06 12:13:14.555555)) - cast((cast(dayofweek(%(2099-01-06 12:13:14.555555))) - cast(1)))) - (cast(1900-01-01) - cast((cast(dayofweek(1900-01-01)) - cast(1))))))) * cast(cast(10)))) / cast(cast(7))) / cast(cast(10)))) / cast(001)))), (_DIVISION_4_ = 'ab'), (_DIVISION_5_ = <min>), (PC1 = %(2009-12-06 12:13:14)), (PC2 = %(2099-01-06 12:13:14.555555)), (PC3 = 'ab'), (PC4 = <min>) end_key: (_SALT_ = <max>), (_DIVISION_1_ = DATE_PART('YEARQUARTER',%(2009-12-06 12:13:14))), (_DIVISION_2_ = 'abcf'), (_DIVISION_3_ = cast((cast(((cast((cast(cast(((cast(%(2099-01-06 12:13:14.555555)) - cast((cast(dayofweek(%(2099-01-06 12:13:14.555555))) - cast(1)))) - (cast(1900-01-01) - cast((cast (dayofweek(1900-01-01)) - cast(1))))))) * cast(cast(10)))) / cast(cast(7))) / cast(cast(10)))) / cast(001)))), (_DIVISION_4_ = 'ab'), (_DIVISION_5_ = <max>), (PC1 = %(2009-12-06 12:13:14)), (PC2 = %(2099-01-06 12:13:14.555555)), (PC3 = 'abcf'), (PC4 = <max>) --- 1 row(s) selected. >>-- ("_DIVISION_1_", "_DIVISION_2_", "_DIVISION_3_", "_DIVISION_4_") has (=, >>between, = between, none) predicates @@ -1038,7 +1038,7 @@ TRAFODION_SCAN MTDN3 OPERATOR TNAME BKEY EKEY ------------------------------ ------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -TRAFODION_SCAN MTDN3 begin_key: (_SALT_ = <min>), (_DIVISION_1_ = DATE_PART('YEARQUARTER',%(2009-12-06 12:13:14))), (_DIVISION_2_ = 'ab '), (_DIVISION_3_ = cast((cast(((cast((cast(((cast(%(2099-01-06 12:13:14.555555)) - cast((cast(dayofweek(%(2099-01-06 12:13:14.555555))) - cast(1)))) - (cast(1900-01-01) - cast((cast(dayofweek(1900-01-01)) - cast(1)))))) * cast(10))) / cast(7)) / cast(10))) / cast(001)))), (_DIVISION_4_ = 'ab'), (_DIVISION_5_ = <min>), (PC1 = %(2009-12-06 12:13:14)), (PC2 = %(2099-01-06 12:13:14.555555)), (PC3 = 'ab'), (PC4 = <min>) end_key: (_SALT_ = <max>), (_DIVISION_1_ = DATE_PART('YEARQUARTER',%(2009-12-06 12:13:14))), (_DIVISION_2_ = 'abcf'), (_DIVISION_3_ = cast((cast(((cast((cast(((cast(%(2099-01-06 12:13:14.555555)) - cast((cast(dayofweek(%(2099-01-06 12:13:14.555555))) - cast(1)))) - (cast(1900-01-01) - cast((cast(dayo fweek(1900-01-01)) - cast(1)))))) * cast(10))) / cast(7)) / cast(10))) / cast(001)))), (_DIVISION_4_ = 'ab'), (_DIVISION_5_ = <max>), (PC1 = %(2009-12-06 12:13:14)), (PC2 = %(2099-01-06 12:13:14.555555)), (PC3 = 'abcf'), (PC4 = <max>) +TRAFODION_SCAN MTDN3 begin_key: (_SALT_ = <min>), (_DIVISION_1_ = DATE_PART('YEARQUARTER',%(2009-12-06 12:13:14))), (_DIVISION_2_ = 'ab '), (_DIVISION_3_ = cast((cast(((cast((cast(cast(((cast(%(2099-01-06 12:13:14.555555)) - cast((cast(dayofweek(%(2099-01-06 12:13:14.555555))) - cast(1)))) - (cast(1900-01-01) - cast((cast(dayofweek(1900-01-01)) - cast(1))))))) * cast(cast(10)))) / cast(cast(7))) / cast(cast(10)))) / cast(001)))), (_DIVISION_4_ = 'ab'), (_DIVISION_5_ = <min>), (PC1 = %(2009-12-06 12:13:14)), (PC2 = %(2099-01-06 12:13:14.555555)), (PC3 = 'ab'), (PC4 = <min>) end_key: (_SALT_ = <max>), (_DIVISION_1_ = DATE_PART('YEARQUARTER',%(2009-12-06 12:13:14))), (_DIVISION_2_ = 'abcf'), (_DIVISION_3_ = cast((cast(((cast((cast(cast(((cast(%(2099-01-06 12:13:14.555555)) - cast((cast(dayofweek(%(2099-01-06 12:13:14.555555))) - cast(1)))) - (cast(1900-01-01) - cast((cast (dayofweek(1900-01-01)) - cast(1))))))) * cast(cast(10)))) / cast(cast(7))) / cast(cast(10)))) / cast(001)))), (_DIVISION_4_ = 'ab'), (_DIVISION_5_ = <max>), (PC1 = %(2009-12-06 12:13:14)), (PC2 = %(2099-01-06 12:13:14.555555)), (PC3 = 'abcf'), (PC4 = <max>) --- 1 row(s) selected. >> http://git-wip-us.apache.org/repos/asf/trafodion/blob/84d76f4d/core/sql/regress/executor/EXPECTED022.SB ---------------------------------------------------------------------- diff --git a/core/sql/regress/executor/EXPECTED022.SB b/core/sql/regress/executor/EXPECTED022.SB index bfa0c4f..30d15eb 100644 --- a/core/sql/regress/executor/EXPECTED022.SB +++ b/core/sql/regress/executor/EXPECTED022.SB @@ -4091,7 +4091,7 @@ Hello (EXPR) (EXPR) (EXPR) ------------- ------------- -------------------------- -10:13:14.0000 10:13:14.0000 2018-04-17 23:19:00.000494 +10:13:14.0000 10:13:14.0000 2018-06-20 20:52:53.000980 --- 1 row(s) selected. >>--test on precision of time @@ -4594,7 +4594,7 @@ lkjihgfedc ? ? >>invoke t022nanos; -- Definition of Trafodion table TRAFODION.SCH.T022NANOS --- Definition current Tue Apr 17 23:19:36 2018 +-- Definition current Wed Jun 20 20:53:22 2018 ( SYSKEY LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE @@ -4655,10 +4655,10 @@ A B C --- 0 row(s) selected. >> ->>process hive ddl 'drop table thivets'; +>>drop table hive.hive.thivets; --- SQL operation complete. ->>process hive ddl 'create table thivets (a timestamp)'; +>>create table hive.hive.thivets (a timestamp); --- SQL operation complete. >>insert into hive.hive.thivets values (timestamp '2018-01-01 >>10:10:10.123456789'); @@ -4692,7 +4692,17 @@ A --- 2 row(s) selected. >> ->>-- error cases +>> +>>-- ERROR CASES +>> +>>-- total precision exceeds Int64 max. +>>create table t022interr(a interval second(12, 9)); + +*** ERROR[3044] The interval SECOND(12,9) is not valid. + +*** ERROR[8822] The statement was not prepared. + +>> >>select timestamp '9999-01-01 10:10:10.123456789' - timestamp '2018-01-01 >>10:10:10.123456' from dual; *** ERROR[8453] This expression results in an invalid interval value '251856000000000000789' http://git-wip-us.apache.org/repos/asf/trafodion/blob/84d76f4d/core/sql/regress/executor/TEST022 ---------------------------------------------------------------------- diff --git a/core/sql/regress/executor/TEST022 b/core/sql/regress/executor/TEST022 index 9cb2af7..d550c37 100755 --- a/core/sql/regress/executor/TEST022 +++ b/core/sql/regress/executor/TEST022 @@ -1163,8 +1163,8 @@ select cast(a as char(30)), cast(b as char(20)), cast(c as char(20)) from t022na select * from t022nanos where a = timestamp '2018-01-01 10:10:10.123456789'; select * from t022nanos where a = timestamp '2018-01-01 10:10:10.123456788'; -process hive ddl 'drop table thivets'; -process hive ddl 'create table thivets (a timestamp)'; +drop table hive.hive.thivets; +create table hive.hive.thivets (a timestamp); insert into hive.hive.thivets values (timestamp '2018-01-01 10:10:10.123456789'); select * from hive.hive.thivets; select * from hive.hive.thivets where a = timestamp '2018-01-01 10:10:10.123456788' + interval '0.000000001' second (1,9); @@ -1172,7 +1172,12 @@ select * from hive.hive.thivets where a = timestamp '2018-01-01 10:10:10.1234567 select extract(second from a), extract(second from b), extract(second from c) from t022nanos; --- error cases + +-- ERROR CASES + +-- total precision exceeds Int64 max. +create table t022interr(a interval second(12, 9)); + select timestamp '9999-01-01 10:10:10.123456789' - timestamp '2018-01-01 10:10:10.123456' from dual; select timestamp '2100-01-01 10:10:10.123456789' - timestamp '2018-01-01 10:10:10.123456' from dual; http://git-wip-us.apache.org/repos/asf/trafodion/blob/84d76f4d/core/sql/regress/udr/TEST100 ---------------------------------------------------------------------- diff --git a/core/sql/regress/udr/TEST100 b/core/sql/regress/udr/TEST100 index 9a9e7b3..8547877 100755 --- a/core/sql/regress/udr/TEST100 +++ b/core/sql/regress/udr/TEST100 @@ -76,9 +76,9 @@ obey TEST100(java_compile); obey TEST100(set_up); obey TEST100(tests); log; ---obey TEST100(clean_up_procs); ---obey TEST100(clean_up_tables); ---obey TEST100(clean_up_files); +obey TEST100(clean_up_procs); +obey TEST100(clean_up_tables); +obey TEST100(clean_up_files); exit; ?section clean_up_files
