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 MaxCompute V2.0 data types. 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 Hive-compatible data types. 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, MaxCompute allows you to 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 MaxCompute V2.0 data types. 
    setproject odps.sql.decimal.odps2=false; -- Disable the DECIMAL type in MaxCompute V2.0. 
    setproject odps.sql.hive.compatible=false; -- Disable Hive-compatible data types. 

    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 MaxCompute V2.0 data types. 
    setproject odps.sql.decimal.odps2=true; -- Enable the DECIMAL data type in MaxCompute V2.0. 
    setproject odps.sql.hive.compatible=false; -- Disable Hive-compatible data types. 

    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 MaxCompute V2.0 data types. 
    setproject odps.sql.decimal.odps2=true; -- Enable the DECIMAL type in MaxCompute V2.0. 
    setproject odps.sql.hive.compatible=true; -- Enable Hive-compatible data types. 

    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, Query editor, MaxCompute Studio, or DataWorks to view the properties of an existing 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, MaxCompute Studio, or DataWorks to change the data type edition of the project.
-- View the data type edition of a project. 
setproject; 
-- Enable or disable MaxCompute V2.0 data types. 
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 Hive-compatible data types. 
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.