MaxCompute V2.0 supports two data type editions: the MaxCompute V2.0 data type edition and the 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 provides three parameters to configure data type editions:
  • odps.sql.type.system.odps2: used to enable or disable MaxCompute V2.0 data types. Valid values: true and false.
  • odps.sql.decimal.odps2: used to enable or disable the DECIMAL type in MaxCompute V2.0. Valid values: true and false.
  • odps.sql.hive.compatible: used to enable or disable Hive-compatible data types. Valid values: true and 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 the proper data type edition. The default settings for each edition are as follows:
  • MaxCompute V1.0 data type edition
    setproject odps.sql.type.system.odps2=false;-- Disables MaxCompute V2.0 data types.
    setproject odps.sql.decimal.odps2=false;-- Disables the DECIMAL type in MaxCompute V2.0.
    setproject odps.sql.hive.compatible=false;-- Disables 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;-- Enables MaxCompute V2.0 data types.
    setproject odps.sql.decimal.odps2=true;-- Enables the DECIMAL type in MaxCompute V2.0.
    setproject odps.sql.hive.compatible=false;-- Disables Hive-compatible data types.

    The MaxCompute V2.0 data type edition is suitable for MaxCompute projects that do not contain 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;-- Enables MaxCompute V2.0 data types.
    setproject odps.sql.decimal.odps2=true;-- Enables the DECIMAL type in MaxCompute V2.0.
    setproject odps.sql.hive.compatible=true;-- Enables 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 supported by other Alibaba Cloud products or components, see Compatibility between components and data types.

Select a data type edition

If you create a workspace in the DataWorks console, you can select a data type edition.

The data type edition affects the following items:
  • Data types of a table
  • Behavior of DML statements and built-in functions
  • Development components closely related to MaxCompute
Therefore, 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

Run the following command to view the properties 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.

Modify the data type edition of a project

If the selected data type edition cannot meet your requirements, you can modify the data type edition.

Run the following commands to modify the data type edition of a project as the project owner or a user assigned the Super_Administrator role:
-- 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 modify the data type edition of a project based on the following rules:
  • The project uses the MaxCompute V2.0 data type edition, but certain 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 together with the commands in a session to set the data type edition of the session to the MaxCompute V1.0 data type edition:
      set odps.sql.type.system.odps2=false;

      This command can only be in lowercase.

  • The project uses the MaxCompute V2.0 data type edition. However, some SQL features use MaxCompute V1.0 data types, and other features, such as the CURRENT_TIMESTAMP function, use 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 separate sessions and set the data type edition for these sessions to the MaxCompute V1.0 data type edition.
    • Rewrite SQL statements to support alternatives.
  • The project uses the MaxCompute V2.0 data type edition at the early stage but 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 to the created table.