TMUDF: Unsigned numeric is mapped to TypeInfo::NUMERIC
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Trafodion |
Fix Released
|
Medium
|
Hans Zeller |
Bug Description
Unsigned numeric data type is mapped to TypeInfo::NUMERIC internally, as opposed to TypeInfo:
The following example takes 2 columns from the input table and returns the data types in character strings as the first 2 columns of the output table. The 3rd column o3 in the output table is declared at the define function time as a numeric unsigned column:
void QATmudf:
{
while (getNextRow(info))
{
for (int i = 0; i < info.in(
{
char val[25];
sprintf(val, "c[%d]: %s", i+1,
info.
}
// the last output column is a numeric unsigned
info.
emitRow(info);
}
}
As shown in the execution output, the data types for both c1 and c2 are mapped to TypeInfo::NUMERIC, even though c2 should be mapped to TypeInfo:
This is seen on the v0324 build installed on a workstation.
To reproduce this problem:
(1) Download the attached tar file and untar it to get the 3 files in there. Put the files in any directory <mydir>.
(2) Make sure that you have run ./sqenv.sh of your Trafodion instance first as building UDF needs $MY_SQROOT for the header files.
(3) Change the line "create library qaTmudfLib file '<mydir>
(4) From sqlci, obey mytest.sql
-------
Here is the execution output:
>>create schema mytest;
--- SQL operation complete.
>>set schema mytest;
--- SQL operation complete.
>>
>>create library qaTmudfLib file '<mydir>
--- SQL operation complete.
>>
>>create table mytable (
+>c1 numeric(9,2),
+>c2 numeric(9,2) unsigned
+>);
--- SQL operation complete.
>>
>>insert into mytable values (-11.11, 22.22);
--- 1 row(s) inserted.
>>
>>create table_mapping function qaTmudfGeneral()
+>returns (
+>o1 char(25),
+>o2 char(25),
+>o3 numeric(9,2) unsigned
+>)
+>external name 'QA_TMUDF'
+>language cpp
+>library qaTmudfLib;
--- SQL operation complete.
>>
>>select * from mytable;
C1 C2
------------ -----------
-11.11 22.22
--- 1 row(s) selected.
>>
>>select * from UDF(qaTmudfGene
O1 O2 O3
-------
c[1]: TypeInfo::NUMERIC c[2]: TypeInfo::NUMERIC -33.33
--- 1 row(s) selected.
>>
>>drop schema mytest cascade;
--- SQL operation complete.
Changed in trafodion: | |
assignee: | nobody → Hans Zeller (hans-zeller) |
Changed in trafodion: | |
status: | New → In Progress |
A fix was committed to the R1.1 branch on 3/31/15. /review. trafodion. org/1415
https:/