Updated on 2024-10-09 GMT+08:00

Modifying a CarbonData Table

SET and UNSET

When you run the SET command, all the attributes of the new SET overwrite the existing properties.

  • SORT SCOPE

    An example of the SET SORT SCOPE command is as follows:

    ALTER TABLE tablename SET TBLPROPERTIES('SORT_SCOPE'='no_sort')

    After the UNSET SORT SCOPE command is executed, the default option NO_SORT is used.

    Example for UNSET SORT SCOPE:

    ALTER TABLE tablename UNSET TBLPROPERTIES('SORT_SCOPE')

  • SORT COLUMNS

    Example for SET SORT COLUMNS:

    ALTER TABLE tablename SET TBLPROPERTIES('SORT_COLUMNS'='column1')

    This command applies new setting of SORT_COLUMNS to new imports. You can adjust SORT_COLUMNS to get optimal query result, but the old data will not be changed. Query performance of historical segments is not affected they are not queried based on the new SORT_COLUMNS.

    The UNSET command is not supported. Instead, you can set SORT_COLUMNS to an empty string.

    ALTER TABLE tablename SET TBLPROPERTIES('SORT_COLUMNS'='')

    • In later versions, custom merge will be enhanced to sort old segments again.
    • SORT_COLUMNS cannot be modified for streaming tables.
    • If an inverted index column is removed from SORT_COLUMNS, no inverted index will be created for the column. The old INVERTED_INDEX settings will not change.