Data type version guide
MaxCompute provides three data type versions: V1.0, V2.0, and Hive-compatible. You can select a version based on your business needs. This topic describes these three versions and explains how to select, view, and modify the data type version for a project.
MaxCompute data type versions
MaxCompute uses the following three parameters to set the data type version property:
odps.sql.type.system.odps2: Enables or disables the MaxCompute V2.0 data type version. The property value can be True or False.
odps.sql.decimal.odps2: Specifies whether to enable the Decimal data type for MaxCompute V2.0. The value of this property can be set to True or False.
odps.sql.hive.compatible: Enables or disables the Hive-compatible mode. In this mode, some data types and SQL behaviors are compatible with Hive. The property value can be True or False.
When you create a new project, you can select one of the three data type versions. The default settings for each version are as follows:
V1.0 data type version
setproject odps.sql.type.system.odps2=false; --Disables the MaxCompute V2.0 data type. setproject odps.sql.decimal.odps2=false; --Disables the Decimal 2.0 data type. setproject odps.sql.hive.compatible=false; --Disables Hive-compatible mode.Use this version for older MaxCompute projects whose dependent components do not support the V2.0 data type version.
V2.0 data type version
setproject odps.sql.type.system.odps2=true; --Enables the MaxCompute V2.0 data type. setproject odps.sql.decimal.odps2=true; --Enables the Decimal 2.0 data type. setproject odps.sql.hive.compatible=false; --Disables Hive-compatible mode.Use this version for MaxCompute projects that had no historical data before April 2020 and whose dependent components support the V2.0 data type version.
Hive-compatible data type version
setproject odps.sql.type.system.odps2=true; --Enables the MaxCompute V2.0 data type. setproject odps.sql.decimal.odps2=true; --Enables the Decimal 2.0 data type. setproject odps.sql.hive.compatible=true; --Enables Hive-compatible mode.Use this version for MaxCompute projects migrated from Hadoop whose dependent components support the V2.0 data type version.
For more information about data type support in other Alibaba Cloud products or components, see Component and data type compatibility.
Select a data type version
The data type version selected for a project affects the following items:
Data types of tables.
Behavior of DML statements and built-in functions.
Development components that are closely related to MaxCompute.
Therefore, before you select a data type version for your project, review the descriptions and differences of each version. For more information, see Differences from other data type versions.
View the data type version of a project
You can run the following command on the MaxCompute client to view the properties of an existing project.
setproject;Check the odps.sql.type.system.odps2, odps.sql.decimal.odps2, and odps.sql.hive.compatible properties to determine the current data type version of the project.
Modify the data type version of a project
If the current data type version of a project does not meet your business needs, you can modify the version.
A project administrator (Project Owner) or a user with the super administrator role (Super_Administrator Role) can run the following command on the MaxCompute client, in DataWorks, or in MaxCompute Studio to modify the data type version of a project.
In an ODPS SQL node in DataWorks Data Studio, do not run SET SQL statements alone. Execute them together with a SELECT or INSERT statement.
--View the data type version of the project.
setproject;
--Enable/Disable the MaxCompute V2.0 data type version.
setproject odps.sql.type.system.odps2=true/false;
--Enable/Disable the decimal 2.0 data type.
setproject odps.sql.decimal.odps2=true/false;
--Enable/Disable the Hive-compatible data type version.
setproject odps.sql.hive.compatible=true/false;Consider the following suggestions when you modify the version:
If your project uses the V2.0 data type version but a required component does not support V2.0 data types, use one of the following methods to resolve the integration issue:
Change the project to the V1.0 data type version.
When a task integrates with a component that does not support V2.0 data types, set the session to use the V1.0 data type version.
NoteTo set the session to the V1.0 data type version, submit the following statement together with the other commands in the session. This command must be in lowercase.
set odps.sql.type.system.odps2=false;
If your project uses the V2.0 data type version but some SQL statements require V1.0 data types while other features, such as the current_timestamp function, depend on V2.0 data types, use one of the following solutions:
Split the SQL statements into a separate session and set the session to use the V1.0 data type version.
Rewrite the SQL statements to use alternative features.
If you change a project from the V2.0 data type version to the V1.0 data type version, note the following points:
When you read data from a table that already uses V2.0 data types, TINYINT, SMALLINT, and INT are converted to BIGINT. CHAR and VARCHAR are converted to STRING.
Create a table that uses V1.0 data types. Use the CAST function to import data from the V2.0 table into the V1.0 table. This action converts the data from V2.0 data types to V1.0 data types.