MaxCompute V2.0 supports two data type editions: MaxCompute V2.0 data type edition and Hive-compatible data type edition. These editions are compatible with mainstream open source products. In addition to these editions, MaxCompute still supports the MaxCompute V1.0 data type edition.
Data type editions supported by MaxCompute
- odps.sql.type.system.odps2: specifies whether to enable the MaxCompute V2.0 data type edition. Valid values: true or false.
- odps.sql.decimal.odps2: specifies whether to enable the DECIMAL type in MaxCompute V2.0. Valid values: true or false.
- odps.sql.hive.compatible: specifies whether to enable the Hive-compatible data type edition. Valid values: true or false. In the Hive-compatible data type edition, some data types and SQL statements are compatible with Hive.
- MaxCompute V1.0 data type edition
setproject odps.sql.type.system.odps2=false; -- Disable the MaxCompute V2.0 data type edition. setproject odps.sql.decimal.odps2=false; -- Disable the DECIMAL type in MaxCompute V2.0. setproject odps.sql.hive.compatible=false; -- Disable the Hive-compatible data type edition.
The MaxCompute V1.0 data type edition is suitable for early MaxCompute projects whose dependent components do not support the MaxCompute V2.0 data type edition.
- MaxCompute V2.0 data type edition
setproject odps.sql.type.system.odps2=true; -- Enable the MaxCompute V2.0 data type edition. setproject odps.sql.decimal.odps2=true; -- Enable the DECIMAL data type in MaxCompute V2.0. setproject odps.sql.hive.compatible=false; -- Disable the Hive-compatible data type edition.
The MaxCompute V2.0 data type edition is suitable for MaxCompute projects that do not contain baseline data before April 2020 and whose dependent components support the MaxCompute V2.0 data type edition.
- Hive-compatible data type edition
setproject odps.sql.type.system.odps2=true; -- Enable the MaxCompute V2.0 data type edition. setproject odps.sql.decimal.odps2=true; -- Enable the DECIMAL type in MaxCompute V2.0. setproject odps.sql.hive.compatible=true; -- Enable the Hive-compatible data type edition.
The Hive-compatible data type edition is suitable for MaxCompute projects that are migrated from Hadoop and whose dependent components support the MaxCompute V2.0 data type edition.
Select a data type edition
- Data types of a table
- Execution of DML statements and built-in functions
- Development components that are closely related to MaxCompute
View the data type edition of a project
setproject;
Check the values of odps.sql.type.system.odps2, odps.sql.decimal.odps2, and odps.sql.hive.compatible to determine the data type edition of the project.
Change the data type edition of a project
If the selected data type edition cannot meet your requirements, you can change the data type edition.
-- View the data type edition of a project.
setproject;
-- Enable or disable the MaxCompute V2.0 data type edition.
setproject odps.sql.type.system.odps2=true/false;
-- Enable or disable the DECIMAL type in MaxCompute V2.0.
setproject odps.sql.decimal.odps2=true/false;
-- Enable or disable the Hive-compatible data type edition.
setproject odps.sql.hive.compatible=true/false;
- The project uses the MaxCompute V2.0 data type edition, but some dependent components do not support MaxCompute V2.0 data types. You can use one of the following methods to address this issue:
- Change the data type edition of the project to the MaxCompute V1.0 data type edition.
- Set the session-level data type edition to the MaxCompute V1.0 data type edition for the components that do not support the MaxCompute V2.0 data type edition. Note Commit the following command with the commands in a session to set the data type edition of the session to the MaxCompute V1.0 data type edition. The command must be in lowercase.
set odps.sql.type.system.odps2=false;
- The project uses the MaxCompute V2.0 data type edition. However, some SQL statements must use MaxCompute V1.0 data types, and some features, such as the current_timestamp function, use the MaxCompute V2.0 data types. You can use one of the following methods to address this issue:
- Split SQL statements that require MaxCompute V1.0 data types into multiple sessions and set the data type edition for these sessions to the MaxCompute V1.0 data type edition.
- Rewrite SQL statements.
- The project uses the MaxCompute V2.0 data type edition at the early stage. However, the project needs to use the MaxCompute V1.0 data type edition at later stages. You can use one of the following methods to address this issue:
- To read the data of a table that uses MaxCompute V2.0 data types, convert data of the TINYINT, SMALLINT, or INT type to the BIGINT type, and data of the CHAR or VARCHAR type to the STRING type.
- Create a table that uses MaxCompute V1.0 data types and then use the CAST function to import the data of a table that uses MaxCompute V2.0 data types into the created table.