Every column in a table has a name and a data type. The data type tells Snowflake how much physical storage to set aside for the column and the form in which the data is stored. For more information about Snowflake data types and to determine which data types are available for your version of Snowflake, see your Snowflake documentation.
For information about Snowflake data types and to determine which data types are available for your version of Snowflake, see your Snowflake documentation.
Here are the data types that the Snowflake engine supports.
| ARRAY | TEXT |
| CHAR, CHARACTER | VARCHAR(n) |
| OBJECT | VARIANT |
| STRING |
| BIGINT | INT |
| BOOLEAN | INTEGER |
| DECIMAL | NUMBER(p,s) |
| DOUBLE | NUMERIC |
| DOUBLE PRECISION | REAL |
| FLOAT | SMALLINT |
| FLOAT4 | TINYINT |
| FLOAT8 |
| DATE | TIMESTAMP_LTZ |
| DATETIME | TIMESTAMP_NTZ |
| TIME | TIMESTAMP_TZ |
| TIMESTAMP |
This table shows the default formats that SAS/ACCESS Interface to Snowflake assigns to SAS variables when using the LIBNAME statement to read from a Snowflake table. These default formats are based on Snowflake column attributes. SAS/ACCESS does not support Snowflake data types that do not appear in this table.
|
Snowflake Data Type |
SAS Data Type |
Default SAS Format |
|---|---|---|
|
ARRAY |
character |
$w., where w is the minimum of 32767 and the value of the DBMAX_TEXT= option |
|
BINARY(n) |
character |
$HEXw. |
|
CHAR, CHARACTER |
character |
synonymous with VARCHAR except that the default length is VARCHAR(1) |
|
OBJECT |
character |
$w., where w is the minimum of 32767 and the value of the DBMAX_TEXT= option** |
|
STRING |
character |
synonymous with VARCHAR |
|
TEXT |
character |
synonymous with VARCHAR |
|
VARCHAR(n) |
character |
$w. |
|
VARIANT |
character |
$w., where w is the minimum of 32767 and the value of the DBMAX_TEXT= option** |
|
BIGINT |
numeric |
synonymous with NUMBER |
|
BOOLEAN |
numeric |
1. |
|
DECIMAL |
numeric |
synonymous with NUMBER |
|
DOUBLE |
numeric |
synonymous with FLOAT |
|
DOUBLE PRECISION |
numeric |
synonymous with FLOAT |
|
FLOAT |
numeric |
none Snowflake uses double-precision (64-bit) IEEE 754 floating point numbers. |
|
FLOAT4 |
numeric |
none Snowflake uses double-precision (64-bit) IEEE 754 floating point numbers. |
|
FLOAT8 |
numeric |
none Snowflake uses double-precision (64-bit) IEEE 754 floating point numbers. |
|
INT |
numeric |
synonymous with NUMBER |
|
INTEGER |
numeric |
synonymous with NUMBER |
|
NUMBER(p,s) |
numeric |
w.d If the precision or scale does not fit into SAS w.d format, use the default format, which means that no format is specified. |
|
NUMERIC |
numeric |
synonymous with NUMBER |
|
REAL |
numeric |
synonymous with FLOAT |
|
SMALLINT |
numeric |
synonymous with NUMBER |
|
TINYINT |
numeric |
synonymous with NUMBER |
|
DATE |
numeric |
DATE9. |
|
DATETIME |
numeric |
DATETIMEw.d, where w and w depend on precision Alias for TIMESTAMP_NTZ. |
|
TIME |
numeric |
TIME8. |
|
TIMESTAMP |
numeric |
DATETIMEw.d, where w and w depend on precision* |
|
TIMESTAMP_LTZ |
numeric |
DATETIMEw.d, where w and w depend on precision* |
|
TIMESTAMP_NTZ |
numeric |
DATETIMEw.d, where w and w depend on precision* |
|
TIMESTAMP_TZ |
numeric |
DATETIMEw.d, where w and w depend on precision* |
|
VARBINARY |
|
synonymous with BINARY** |
*TIMESTAMP data types: SAS/ACCESS Interface for Snowflake sets the TIMESTAMP data type alias to map to TIMESTAMP without time zone. When the connection to Snowflake is established, these commands are executed.
ALTER SESSION SET TIMESTAMP_TYPE_MAPPING = TIMESTAMP_NTZ ALTER SESSION SET CLIENT_TIMESTAMP_TYPE_MAPPING = TIMESTAMP_NTZ ALTER SESSION SET WEEK_START=7
**Semi-structured data types: The ODBC driver describes these as SQL_VARCHAR, and they are read into SAS as a string. To read semi-structured data elements, use explicit SQL pass-through to submit SQL queries using special operators and functions.
Here is an example of semi-structured data.
libname snow dsn='snowflake' user=myusr1 pw=mypwd1
schema=myschema;
proc sql noerrorstop;
connect using snow;
execute (
CREATE OR REPLACE TABLE "myClass" ( "src" variant )
AS
SELECT PARSE_JSON(column1) AS "src"
FROM VALUES
('{
"Name" : "Alfred",
"Sex" : "M",
"Age" : 14,
"Measurements" : {
"Height": 69.0,
"Weight" : 112.5
}
}'),
('{
"Name" : "Alice",
"Sex" : "F",
"Age" : 13,
"Measurements" : {
"Height": 56.5,
"Weight" : 84.0
}
}') ) by snow;
disconnect from snow;
quit;
proc print data=snow.myClass;
title 'proc print myClass';
run;
title 'Traversing semi-structured data';
proc sql;
connect using snow;
select name, sex from connection to snow
(select "src":Name as name, "src":Sex as sex from SASUSER."myClass");
disconnect from snow;
quit;
title 'Traversing semi-structured data - type specified';
proc sql;
connect using snow;
select name, sex from connection to snow
(select "src":Name::char(10) as name,
"src":Sex::char(1) as sex from SASUSER."myClass");
disconnect from snow;
quit;
The first PROC PRINT statement prints the semi-structured data in a string. The first SQL step uses the colon (:) notation to read a first-level element of the semi-structured data. In the second SQL step, a type specification is added.
proc print myClass 09:06 Thursday, November 22, 2018 2
Obs src
1 {
"Age": 14,
"Measurements": {
"Height": 69,
"Weight": 112.5
},
"Name": "Alfred",
"Sex": "M"
}
2 {
"Age": 13,
"Measurements": {
"Height": 56.5,
"Weight": 84
},
"Name": "Alice",
"Sex": "F"
}
Traversing semi-structured data 09:06 Thursday, November 22, 2018 4
NAME SEX
--------------------------------------------------------------------------
"Alfred" "M"
"Alice" "F"
Traversing semi-structured data, type specified 09:06 Thursday, November 22, 2018 5
NAME SEX
---------------
Alfred M
Alice F
The next table shows the default Snowflake data types that SAS/ACCESS assigns to SAS variable formats during output operations when you use the LIBNAME statement.
|
SAS Data Type |
SAS Variable Format |
Snowflake Data Type |
|---|---|---|
|
character |
$HEXw. |
BINARY(n1 ) |
|
character |
$w. |
VARCHAR(n1 ) |
|
numeric |
datetime formats |
TIMESTAMP |
|
numeric |
date formats |
DATE |
|
numeric |
time formats |
TIME |
|
numeric |
w.d. |
NUMBER(p,s) |
|
numeric |
other numerics |
DOUBLE |
| 1 In a Snowflake data type, n is equivalent to w in SAS formats. | ||