Problem Note 59056: SAS/ACCESS® Interface to Impala truncates decimal types
When you use SAS/ACCESS Interface to Impala, decimals might be truncated or might be displayed as integers. Here is
an example that shows how to replicate the problem.
proc sql noerrorstop;
connect to impala (user=user-id password=password dsn=data-source-name);
execute (drop table table-name) by impala;
execute (create table table-name ( bigdecone decimal(5,4) )) by impala;
execute (insert into table-name values (cast('0.0011' as decimal(5,4))) ) by impala;
quit;
libname test impala user=user-id password=password dsn=data-source-name;
proc sql;
select bigdecone from test.table-name;
quit;
The results from this code show a value of 0 for the variable bigdecone instead of .0011. The problem occurs because Impala decimal fields are a new feature.
To circumvent the problem, complete the following steps:
- Determine the length of the decimal field in the table by using the following code:
proc sql;
connect to impala as sql1 (user=user-id password=password dsn=data-source-name);
create table mytablecolumnstats as
select * from connection to sql1
(show column stats table-name);
quit;
proc print data=mytablecolumnstats;
title 'my column stats table-name';
run;
- Use either a FORMAT function or a CAST function to set the length of the decimal field.
For example, you can use a FORMAT function in a LIBNAME statement to set the variable to the correct length as shown below:
libname test impala user=user-id password=password dsn=data-source-name;
proc sql;
select bigdecone format=5.4 from test.table-name;
quit;
Another option is to use the PRINT procedure with a FORMAT statement as shown in this example:
libname test impala user=user-id password=password dsn=data-source-name;
proc print data=test.table-name;
format bigdecone 5.4 ;
run;
- If you are using SQL pass-through, you must use a CAST function to recast the value as a float
as shown below:
proc sql;
connect to impala as sql1 (user=user-id password=password dsn=data-source-name);
select * from connection to sql1
(select cast(bigdecone as float )from table-name);
quit;
Operating System and Release Information
| SAS System | SAS/ACCESS Interface to Impala | Microsoft® Windows® for x64 | | |
| 64-bit Enabled AIX | | |
| Linux for x64 | | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
When using SAS/ACCESS Interface to Impala, decimals could be truncated or the variable might
show as a zero. The problem occurs because the SAS/ACCESS Interface to Impala does
not support decimal types. To circumvent the problem, use either a FORMAT function or a CAST function in your code.
| Type: | Problem Note |
| Priority: | high |
| Date Modified: | 2016-10-24 11:08:38 |
| Date Created: | 2016-09-29 16:06:24 |