Github user traflm commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/618#discussion_r72174955
--- Diff: core/sql/optimizer/NATable.cpp ---
@@ -3676,6 +3676,54 @@ NAType* getSQColTypeForHive(const char* hiveType,
NAMemory* heap)
CharInfo::IMPLICIT);
}
+ 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];
+ memset(pstr,0,sizeof(pstr));
+ memset(sstr,0,sizeof(sstr));
+
+ for( i = 0; i < hiveTypeLen; i++ )
+ {
+ if(hiveType[i] == '(' )
+ {
+ pstart = i+1;
+ }
+ else if(hiveType[i] == ',')
+ {
+ pend = i;
+ sstart = i+1;
+ }
+ else if(hiveType[i] == ')')
+ {
+ send = i;
+ }
+ else
+ continue;
+ }
+ if(pend - pstart > 0)
+ {
+ strncpy(pstr,hiveType+pstart, pend-pstart);
+ p=atoi(pstr);
+ }
+ if(send - sstart > 0)
+ {
+ strncpy(sstr,hiveType+sstart,send-sstart);
+ s=atoi(sstr);
+ }
+
+ if( (p>0) && (s>0) )
+ {
+ return new (heap) SQLDecimal( p, s, TRUE, TRUE);
+ }
+ else
+ {
+ return new (heap) SQLDecimal( 10, 0, TRUE, TRUE);
--- End diff --
p>18 is important check, by now, I just raise error if p>18.
Since I cannot find a correct way to use SQLNumeric, It is always be
treated as tinyint for some unknown reason.
Hive allow 'precision' up to 38, so when p>18 it will be great to use
SQLBignum, I didn't realize BIGNUM can be used as Decimal type, will make a
change.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---