Data types
Dataphin uses MaxCompute V2.0 as its compute engine. This topic describes the MaxCompute V2.0 data types that Dataphin supports.
Limitations
The data type system version 2.0 is intended for:
MaxCompute projects created after April 2020 that contain no pre-existing data.
Environments where all dependent product components are also compatible with the version 2.0 type system.
Basic data types
Data type | Constant example | Description |
TINYINT | 1Y and -127Y | 8-bit signed integer. Valid values: -128 to 127. |
SMALLINT | 32767S and -100S | 16-bit signed integer. Valid values: -32768 to 32767. |
INT | 1000 and -15645787 | 32-bit signed integer. Valid values: -231 to 231 -1. |
BIGINT | 100000000000 L and -1L | 64-bit signed integer. Valid values: -263 + 1 to 263 -1. |
BINARY |
| Binary data type. The size limit is 8 MB. Note
|
FLOAT | 3.14F and cast(3.14159261E+7 as float) | 32-bit binary floating-point number. Note A loss of precision occurs when data of the FLOAT type is calculated due to the computer storage and internal computing logic. In scenarios where high precision is required, you can convert data of the FLOAT type into data of the DECIMAL type. |
DOUBLE | 3.14D and 3.14159261E+7 | 64-bit binary floating-point number. Note A loss of precision occurs when data of the DOUBLE type is calculated due to the computer storage and internal computing logic. In scenarios where high precision is required, you can convert data of the DOUBLE type into data of the DECIMAL type. |
DECIMAL(precision,scale) | 3.5BD and 99999999999.9999999BD | The precise numeric type based on the decimal system. The default expression of this data type is
Note
|
VARCHAR(n) | No default value | The variable-length character type, in which n specifies the length. Valid values: 1 to 65535. |
CHAR(n) | No default value | The fixed-length character type, in which n specifies the length. The maximum value is 255. If the length does not reach the specified value, extra spaces are automatically filled but are not involved in the comparison. |
STRING | "abc", 'bcd', "alibaba", and 'inc' | The string type. The maximum length is 8 MB. |
DATE | DATE'2017-11-11' | The date type in the Valid values: 0001-01-01 to 9999-12-31. |
DATETIME | DATETIME'2017-11-11 00:00:00' | The DATETIME type. Valid values: 0001-01-01 00:00:00.000 to 9999-12-31 23:59:59.999, accurate to the millisecond. |
TIMESTAMP | TIMESTAMP'2017-11-11 00:00:00.123456789' | The TIMESTAMP type. Valid values: 0001-01-01 00:00:00.000000000 to 9999-12-31 23:59:59.999999999, accurate to the nanosecond. Note The timestamp is independent of time zones. In any time zone, the timestamp stores a date offset value from Epoch (UTC 1970-01-01 00:00:00). You can use built-in functions to perform time zone-related computing on the data of the TIMESTAMP type. For example, you can use |
TIMESTAMP_NTZ | TIMESTAMP_NTZ '2017-11-11 00:00:00.123456789' | TIMESTAMP data type, which is independent from time zones. Valid values: 0000-01-01 00:00:00.000000000 to 9999-12-31 23:59:59.999999999. |
BOOLEAN | True and False | The BOOLEAN type. Valid values: True and False. |
INTERVAL |
| The INTERVAL type represents a time period and is used to express the interval between two dates or times. It includes two types: INTERVAL_YEAR_MONTH and INTERVAL_DAY_TIME. |
General rules and behavior:
All data types are nullable.
The INT keyword in an SQL statement refers to the 32-bit integer type.
-- Convert a into a 32-bit integer. CAST(a AS INT)By default, an integer constant is processed as the INT type. For example, integer constant 1 in
SELECT 1 + a;is processed as the INT type. If a constant exceeds the value range of the INT type but does not exceed the value range of the BIGINT type, the constant is processed as the BIGINT type. If the constant exceeds the value range of the BIGINT type, the constant is processed as the DOUBLE type.Implicit conversions
Certain implicit conversions (e.g.,
STRINGtoBIGINT,STRINGtoDATETIME,DOUBLEtoBIGINT,DECIMALtoDOUBLE,DECIMALtoBIGINT) are disabled to prevent potential data loss or errors. Use theCASTfunction for explicit conversions.Constants of the VARCHAR type can be implicitly converted into the STRING type.
Tables, Functions, and UDFs
Built-in functions that use 2.0 data types operate correctly in the 2.0 data type system.
UDFs are resolved and overloaded based on the 2.0 data type system.
Partition columns support
STRING,VARCHAR,CHAR,TINYINT,SMALLINT,INT, andBIGINTdata types.
MaxCompute automatically concatenates multiple adjacent string literals. For example,
select 'abc' 'efg' 'ddt';returnsabcefgddt.When inserting a constant into a
DECIMALfield, the constant's format must match its definition. For example:INSERT INTO test_tb(a) VALUES (3.5BD)DATETIMEqueries do not display milliseconds by default. To display milliseconds, use the-dfpflag in Tunnel commands, such astunnel upload -dfp 'yyyy-MM-dd HH:mm:ss.SSS'. For more information about Tunnel commands, see Tunnel commands.
Complex data types
Data type | Definition | Constructor |
ARRAY |
|
|
MAP |
|
|
STRUCT |
|
|