Class SchemaEvolutionUtils


  • public class SchemaEvolutionUtils
    extends Object
    Schema evolution utils for maxcompute.
    • Method Detail

      • createTable

        public static void createTable​(MaxComputeOptions options,
                                       TableId tableId,
                                       Schema schema)
                                throws com.aliyun.odps.OdpsException
        equals to run a sql like: create table table_name (col_name1 type1 comment [, col_name2 type2 ...]);.
        Throws:
        com.aliyun.odps.OdpsException
      • addColumns

        public static void addColumns​(MaxComputeOptions options,
                                      TableId tableId,
                                      List<AddColumnEvent.ColumnWithPosition> columns)
                               throws com.aliyun.odps.OdpsException
        equals to run a sql like: 'alter table table_name add columns (col_name1 type1 comment [, col_name2 type2 ...]);'.
        Throws:
        com.aliyun.odps.OdpsException
      • alterColumnType

        public static void alterColumnType​(MaxComputeOptions options,
                                           TableId tableId,
                                           Map<String,​DataType> typeMapping,
                                           Map<String,​String> comments)
                                    throws com.aliyun.odps.OdpsException
        equals to run a sql like: 'alter table table_name change column old_column_name new_column_name new_data_type;'. and 'alter table table_name change column col_name comment 'col_comment'';
        Throws:
        com.aliyun.odps.OdpsException
      • dropColumn

        public static void dropColumn​(MaxComputeOptions options,
                                      TableId tableId,
                                      List<String> droppedColumnNames)
                               throws com.aliyun.odps.OdpsException
        equals to run a sql like: 'alter table table_name drop columns col_name1[, col_name2...];'.
        Throws:
        com.aliyun.odps.OdpsException
      • renameColumn

        public static void renameColumn​(MaxComputeOptions options,
                                        TableId tableId,
                                        Map<String,​String> nameMapping)
                                 throws com.aliyun.odps.OdpsException
        equals to run a sql like: 'alter table table_name change column old_col_name rename to new_col_name;'.
        Throws:
        com.aliyun.odps.OdpsException
      • dropTable

        public static void dropTable​(MaxComputeOptions options,
                                     TableId tableId)
                              throws com.aliyun.odps.OdpsException
        Throws:
        com.aliyun.odps.OdpsException
      • truncateTable

        public static void truncateTable​(MaxComputeOptions options,
                                         TableId tableId)
                                  throws com.aliyun.odps.OdpsException
        Throws:
        com.aliyun.odps.OdpsException
      • alterTableComment

        public static void alterTableComment​(MaxComputeOptions options,
                                             TableId tableId,
                                             String comment)
                                      throws com.aliyun.odps.OdpsException
        Throws:
        com.aliyun.odps.OdpsException