aws-glue-datacatalog-spark-client/src/main/java/com/amazonaws/glue/catalog/metastore/AWSCatalogMetastoreClient.java [512:548]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  public void createIndex(Index index, org.apache.hadoop.hive.metastore.api.Table indexTable) throws InvalidObjectException, MetaException, NoSuchObjectException,
        TException, org.apache.hadoop.hive.metastore.api.AlreadyExistsException {
      boolean dirCreated = glueMetastoreClientDelegate.validateNewTableAndCreateDirectory(indexTable);
      boolean indexTableCreated = false;
      String dbName = index.getDbName();
      String indexTableName = index.getIndexTableName();
      String originTableName = index.getOrigTableName();
      Path indexTablePath = new Path(indexTable.getSd().getLocation());
      Table catalogIndexTableObject = HiveToCatalogConverter.convertIndexToTableObject(index);
      String indexTableObjectName = INDEX_PREFIX + index.getIndexName();

      try {
          org.apache.hadoop.hive.metastore.api.Table originTable = getTable(dbName, originTableName);
          Map<String, String> parameters = originTable.getParameters();
          if (parameters.containsKey(indexTableObjectName)){
              throw new org.apache.hadoop.hive.metastore.api.AlreadyExistsException("Index: " + index.getIndexName() + " already exist");
          }
          createTable(indexTable);
          indexTableCreated = true;
          originTable.getParameters().put(indexTableObjectName, catalogTableToString(catalogIndexTableObject));
          alter_table(dbName, originTableName, originTable);
      } catch (Exception e) {
          if (dirCreated){
              wh.deleteDir(indexTablePath, true);
          }
          if (indexTableCreated) {
              dropTable(dbName, indexTableName);
          }
          String msg = "Unable to create index: ";
          logger.error(msg, e);
          if (e instanceof TException) {
              throw e;
          } else {
              throw new MetaException(msg + e);
          }
      }
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



aws-glue-datacatalog-hive2-client/src/main/java/com/amazonaws/glue/catalog/metastore/AWSCatalogMetastoreClient.java [613:649]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  public void createIndex(Index index, org.apache.hadoop.hive.metastore.api.Table indexTable) throws InvalidObjectException, MetaException, NoSuchObjectException,
        TException, org.apache.hadoop.hive.metastore.api.AlreadyExistsException {
    boolean dirCreated = glueMetastoreClientDelegate.validateNewTableAndCreateDirectory(indexTable);
    boolean indexTableCreated = false;
    String dbName = index.getDbName();
    String indexTableName = index.getIndexTableName();
    String originTableName = index.getOrigTableName();
    Path indexTablePath = new Path(indexTable.getSd().getLocation());
    Table catalogIndexTableObject = HiveToCatalogConverter.convertIndexToTableObject(index);
    String indexTableObjectName = INDEX_PREFIX + index.getIndexName();

    try {
      org.apache.hadoop.hive.metastore.api.Table originTable = getTable(dbName, originTableName);
      Map<String, String> parameters = originTable.getParameters();
      if (parameters.containsKey(indexTableObjectName)){
        throw new org.apache.hadoop.hive.metastore.api.AlreadyExistsException("Index: " + index.getIndexName() + " already exist");
      }
      createTable(indexTable);
      indexTableCreated = true;
      originTable.getParameters().put(indexTableObjectName, catalogTableToString(catalogIndexTableObject));
      alter_table(dbName, originTableName, originTable);
    } catch (Exception e) {
      if (dirCreated){
        wh.deleteDir(indexTablePath, true);
      }
      if (indexTableCreated) {
        dropTable(dbName, indexTableName);
      }
      String msg = "Unable to create index: ";
      logger.error(msg, e);
      if (e instanceof TException) {
        throw e;
      } else {
        throw new MetaException(msg + e);
      }
    }
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



