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

MaxCompute allows you to configure data type editions by using the following parameters:
  • 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.
When you add a project in MaxCompute, you can choose a proper data type edition. Default settings for each data type edition:
  • 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.

Note For more information about data types that are supported by other Alibaba Cloud services or components, see Compatibility between components and data types.

Select a data type edition

The data type edition affects the following items:
  • Data types of a table
  • Execution of DML statements and built-in functions
  • Development components that are closely related to MaxCompute
Before you select a data type edition for a project, we recommend that you read and fully understand the descriptions and differences of data type editions. For more information, see Differences between the MaxCompute V2.0 data type edition and other data type editions.

View the data type edition of a project

You can run the following command on the MaxCompute client to view the properties of the created 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.

If you are the project owner or assigned the Super_Administrator role, you can run the following commands on the MaxCompute client, Query editor in the MaxCompute console, MaxCompute Studio, or DataWorks to change the data type edition of the project.
Important You cannot run the following SET commands separately on an ODPS SQL node of DataStudio in the DataWorks console. You must run the commands together with the SELECT or INSERT SQL statements.
-- 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;
We recommend that you change the data type edition of a project based on the following rules:
  • 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.