Beispiel #1
0
 private AlterTableDesc createMockAlterTableSetProperty(String newTimeZone) {
   AlterTableDesc alterTableDesc = new AlterTableDesc();
   alterTableDesc.setTableName("default.mynewcooltable");
   alterTableDesc.setProperty("timezone", newTimeZone);
   alterTableDesc.setAlterTableType(AlterTableType.SET_PROPERTY);
   return alterTableDesc;
 }
Beispiel #2
0
 private AlterTableDesc createMockAlterTableUnsetProperty(Set<String> keys) {
   AlterTableDesc alterTableDesc = new AlterTableDesc();
   alterTableDesc.setTableName("default.mynewcooltable");
   alterTableDesc.setUnsetPropertyKey(keys);
   alterTableDesc.setAlterTableType(AlterTableType.UNSET_PROPERTY);
   return alterTableDesc;
 }
Beispiel #3
0
 private AlterTableDesc createMockAlterTableAddColumn() {
   AlterTableDesc alterTableDesc = new AlterTableDesc();
   alterTableDesc.setTableName("default.mynewcooltable");
   alterTableDesc.setAddColumn(new Column("mynewcol", Type.TEXT));
   alterTableDesc.setAlterTableType(AlterTableType.ADD_COLUMN);
   return alterTableDesc;
 }
Beispiel #4
0
 private AlterTableDesc createMockAlterTableName() {
   AlterTableDesc alterTableDesc = new AlterTableDesc();
   alterTableDesc.setTableName("default.mycooltable");
   alterTableDesc.setNewTableName("mynewcooltable");
   alterTableDesc.setAlterTableType(AlterTableType.RENAME_TABLE);
   return alterTableDesc;
 }
Beispiel #5
0
 private AlterTableDesc createMockAlterTableRenameColumn() {
   AlterTableDesc alterTableDesc = new AlterTableDesc();
   alterTableDesc.setTableName("default.mynewcooltable");
   alterTableDesc.setColumnName(FieldName1);
   alterTableDesc.setNewColumnName("ren" + FieldName1);
   alterTableDesc.setAlterTableType(AlterTableType.RENAME_COLUMN);
   return alterTableDesc;
 }
Beispiel #6
0
  private void testDropPartition(String tableName, String partitionName) throws Exception {
    AlterTableDesc alterTableDesc = new AlterTableDesc();
    alterTableDesc.setTableName(tableName);
    alterTableDesc.setAlterTableType(AlterTableType.DROP_PARTITION);

    PartitionDesc partitionDesc = new PartitionDesc();
    partitionDesc.setPartitionName(partitionName);

    alterTableDesc.setPartitionDesc(partitionDesc);

    catalog.alterTable(alterTableDesc);
  }
Beispiel #7
0
  private void testAddPartition(String tableName, String partitionName) throws Exception {
    AlterTableDesc alterTableDesc = new AlterTableDesc();
    alterTableDesc.setTableName(tableName);
    alterTableDesc.setAlterTableType(AlterTableType.ADD_PARTITION);

    alterTableDesc.setPartitionDesc(CatalogTestingUtil.buildPartitionDesc(partitionName));

    catalog.alterTable(alterTableDesc);

    String[] split = IdentifierUtil.splitFQTableName(tableName);

    CatalogProtos.PartitionDescProto resultDesc =
        catalog.getPartition(split[0], split[1], partitionName);

    assertNotNull(resultDesc);
    assertEquals(resultDesc.getPartitionName(), partitionName);
    assertEquals(resultDesc.getPath(), "hdfs://xxx.com/warehouse/" + partitionName);

    assertEquals(resultDesc.getPartitionKeysCount(), 2);
  }