Example #1
0
  private boolean isClonedTable(String orignalTable, String newTable) throws Exception {
    assertTableExists(newTable);
    TableDesc origTableDesc = client.getTableDesc(orignalTable);
    TableDesc newTableDesc = client.getTableDesc(newTable);

    if (isClonedSchema(origTableDesc.getSchema(), newTableDesc.getSchema()) == false) {
      fail("Schema of input tables do not match");
      return false;
    }

    // Check partition information
    PartitionMethodDesc origPartMethod = origTableDesc.getPartitionMethod();
    PartitionMethodDesc newPartMethod = newTableDesc.getPartitionMethod();
    if (origPartMethod != null) {
      if (newPartMethod == null) {
        fail("New table does not have partition info");
        return false;
      }
      if (isClonedSchema(origPartMethod.getExpressionSchema(), newPartMethod.getExpressionSchema())
          == false) {
        fail("Partition columns of input tables do not match");
        return false;
      }

      if (origPartMethod.getPartitionType().equals(newPartMethod.getPartitionType()) == false) {
        fail("Partition type of input tables do not match");
        return false;
      }
    }

    // Check external flag
    if (origTableDesc.isExternal() != newTableDesc.isExternal()) {
      fail("External table flag on input tables not equal");
      return false;
    }

    if (origTableDesc.getMeta() != null) {
      TableMeta origMeta = origTableDesc.getMeta();
      TableMeta newMeta = newTableDesc.getMeta();
      if (origMeta.getDataFormat().equals(newMeta.getDataFormat()) == false) {
        fail("Store type of input tables not equal");
        return false;
      }

      KeyValueSet origOptions = origMeta.getPropertySet();
      KeyValueSet newOptions = newMeta.getPropertySet();
      if (origOptions.equals(newOptions) == false) {
        fail("Meta options of input tables not equal");
        return false;
      }
    }
    return true;
  }