All Products
Search
Document Center

MaxCompute:Data type editions

Last Updated:Feb 19, 2024

MaxCompute provides three data type editions: MaxCompute V1.0 data type edition, MaxCompute V2.0 data type edition, and Hive-compatible data type edition. You can select a data type edition based on your business requirements. This topic describes these data type editions and describes how to select a data type edition for a project and how to view and change the data type edition of a project.

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, 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 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 scenarios in which your project does not contain data generated before April 2020 and depends on components that 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 data 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 the 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 description of each data type edition and differences between the 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 business 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, in the DataWorks console, or in MaxCompute Studio 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 the MaxCompute V2.0 data type edition. 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 the MaxCompute V1.0 data type edition, and some features, such as the current_timestamp function, use the MaxCompute V2.0 data type edition. You can use one of the following methods to address this issue:

    • Split SQL statements that require the MaxCompute V1.0 data type edition 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 the MaxCompute V2.0 data type edition, 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 the MaxCompute V1.0 data type and then use the CAST function to import the data of a table that uses the MaxCompute V2.0 data type edition into the created table.