You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by hz...@apache.org on 2016/07/27 20:29:36 UTC
[2/4] incubator-trafodion git commit: fix comments issues
fix comments issues
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/d2825057
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/d2825057
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/d2825057
Branch: refs/heads/master
Commit: d2825057c8fc59f706d8d1fd26d9e266645b2f9a
Parents: ad6c2f3
Author: Liu Ming <ov...@sina.com>
Authored: Tue Jul 26 13:17:50 2016 +0000
Committer: Liu Ming <ov...@sina.com>
Committed: Tue Jul 26 13:17:50 2016 +0000
----------------------------------------------------------------------
core/sql/optimizer/NATable.cpp | 38 ++++++++++++++++++++++-----
core/sql/regress/hive/EXPECTED005 | 8 +++---
core/sql/regress/hive/TEST005_a.hive.sql | 8 ++++--
core/sql/regress/hive/tbl_type.data | 2 +-
4 files changed, 43 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d2825057/core/sql/optimizer/NATable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.cpp b/core/sql/optimizer/NATable.cpp
index ad6bf86..b59abd3 100644
--- a/core/sql/optimizer/NATable.cpp
+++ b/core/sql/optimizer/NATable.cpp
@@ -86,6 +86,10 @@
#include "CmpMain.h"
#define MAX_NODE_NAME 9
+#define MAX_PRECISION_ALLOWED 18
+#define HIVE_MAX_PRECISION_ALLOWED 38
+#define MAX_SCALE_ALLOWED 6
+#define MAX_NUM_LEN 16
#include "SqlParserGlobals.h"
@@ -3678,9 +3682,9 @@ NAType* getSQColTypeForHive(const char* hiveType, NAMemory* heap)
if ( !strncmp(hiveType, "decimal", 7) )
{
- Int16 i=0, pstart=0, pend=0, sstart=0, send=0, p=0, s = 0;
- Int16 hiveTypeLen = strlen(hiveType);
- char pstr[16], sstr[16];
+ Lng32 i=0, pstart=0, pend=0, sstart=0, send=0, p=-1, s = -1;
+ Lng32 hiveTypeLen = strlen(hiveType);
+ char pstr[MAX_NUM_LEN], sstr[MAX_NUM_LEN];
memset(pstr,0,sizeof(pstr));
memset(sstr,0,sizeof(sstr));
@@ -3702,25 +3706,47 @@ NAType* getSQColTypeForHive(const char* hiveType, NAMemory* heap)
else
continue;
}
+
if(pend - pstart > 0)
{
+ if( (pend - pstart) >= MAX_NUM_LEN ) // too long
+ return NULL;
strncpy(pstr,hiveType+pstart, pend-pstart);
p=atoi(pstr);
}
+
if(send - sstart > 0)
{
+ if( (send - sstart) >= MAX_NUM_LEN ) // too long
+ return NULL;
strncpy(sstr,hiveType+sstart,send-sstart);
s=atoi(sstr);
}
- if( (p>0) && (s>0) )
+ if( (p>0) && (p <= MAX_PRECISION_ALLOWED) ) //have precision between 1 - 18
{
- return new (heap) SQLDecimal( p, s, TRUE, TRUE);
+ if( ( s >=0 ) && ( s<= MAX_SCALE_ALLOWED) ) //have valid scale
+ return new (heap) SQLDecimal( p, s, TRUE, TRUE);
+ else
+ return NULL;
}
- else
+ else if( (p > MAX_PRECISION_ALLOWED) && ( p <= HIVE_MAX_PRECISION_ALLOWED) )
{
+ if ( (s>=0) && ( s< p ) ) //have valid scale
+ return new (heap) SQLBigNum( p, s, TRUE, TRUE, TRUE, NULL);
+ else
+ return NULL;
+ }
+ //no p and s given, p and s are all initial value
+ else if( ( p == -1 ) && ( s == -1 ) )
+ {
+ // hive define decimal as decimal ( 10, 0 )
return new (heap) SQLDecimal( 10, 0, TRUE, TRUE);
}
+ else
+ {
+ return NULL;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d2825057/core/sql/regress/hive/EXPECTED005
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/EXPECTED005 b/core/sql/regress/hive/EXPECTED005
index 38c91d0..273184d 100644
--- a/core/sql/regress/hive/EXPECTED005
+++ b/core/sql/regress/hive/EXPECTED005
@@ -434,10 +434,10 @@ ID CHAPTER ENGLISH TRANSLATOR
>>
>>select * from tbl_type;
-TINT SM I BIG STR F D T DT VC D10 D18
+TINT SM I BIG STR F D T DT VC D10 D18 D181 D30
---- ------ ----------- -------------------- ------------------------- --------------- ------------------------- -------------------------- ---------- ---------------------------------------- ----------- ----------
- 101 202 203 204 two hundred 2.0000000E+002 2.00000000000000000E+002 2022-02-02 22:22:22.222222 2022-02-02 varchar 1234567890 123456.11
+ 101 202 203 204 two hundred 2.0000000E+002 2.00000000000000000E+002 2022-02-02 22:22:22.222222 2022-02-02 varchar 1234567890 123456.11 12345 11111111111111111111111111111
--- 1 row(s) selected.
>>insert into tbl_type_temp select * from tbl_type;
@@ -445,10 +445,10 @@ TINT SM I BIG STR F
--- 1 row(s) inserted.
>>select * from tbl_type_temp;
-TINT SM I BIG STR F D T DT VC D10 D18
+TINT SM I BIG STR F D T DT VC D10 D18 D181 D30
---- ------ ----------- -------------------- ------------------------- --------------- ------------------------- -------------------------- ---------- ---------------------------------------- ----------- ----------
- 101 202 203 204 two hundred 2.0000000E+002 2.00000000000000000E+002 2022-02-02 22:22:22.222222 2022-02-02 varchar 1234567890 123456.11
+ 101 202 203 204 two hundred 2.0000000E+002 2.00000000000000000E+002 2022-02-02 22:22:22.222222 2022-02-02 varchar 1234567890 123456.11 12345 11111111111111111111111111111
--- 1 row(s) selected.
>>
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d2825057/core/sql/regress/hive/TEST005_a.hive.sql
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/TEST005_a.hive.sql b/core/sql/regress/hive/TEST005_a.hive.sql
index 10949dc..0437bbb 100644
--- a/core/sql/regress/hive/TEST005_a.hive.sql
+++ b/core/sql/regress/hive/TEST005_a.hive.sql
@@ -140,7 +140,9 @@ create external table tbl_type
dt date,
vc varchar(10),
d10 decimal,
- d18 decimal(8,2)
+ d18 decimal(8,2),
+ d181 decimal(10),
+ d30 decimal(30)
)
row format delimited fields terminated by '|'
location '/user/hive/exttables/tbl_type';
@@ -159,7 +161,9 @@ create table tbl_type_temp
dt date,
vc varchar(10),
d10 decimal,
- d18 decimal(8,2)
+ d18 decimal(8,2),
+ d181 decimal(10),
+ d30 decimal(30)
)
row format delimited fields terminated by '|';
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d2825057/core/sql/regress/hive/tbl_type.data
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/tbl_type.data b/core/sql/regress/hive/tbl_type.data
index 9e56472..aeb9eb4 100644
--- a/core/sql/regress/hive/tbl_type.data
+++ b/core/sql/regress/hive/tbl_type.data
@@ -1 +1 @@
-101|202|203|204|two hundred|2E2|2E+002|2022-02-02 22:22:22.222222|2022-02-02|varchar|1234567890|123456.11
+101|202|203|204|two hundred|2E2|2E+002|2022-02-02 22:22:22.222222|2022-02-02|varchar|1234567890|123456.11|12345|11111111111111111111111111111