Esempio n. 1
0
 /**
  * Checks the name and schema for known compatibility issues and warns.
  *
  * <p>If the column names are not compatible across components, this will warn the user.
  *
  * @param namespace a String namespace
  * @param datasetName a String dataset name
  * @param schema a {@link Schema}
  */
 public static void checkAndWarn(String namespace, String datasetName, Schema schema) {
   try {
     checkDatasetName(namespace, datasetName);
     checkSchema(schema);
   } catch (IllegalArgumentException e) {
     LOG.warn(e.getMessage());
   } catch (IllegalStateException e) {
     LOG.warn(e.getMessage());
   }
 }
Esempio n. 2
0
 /**
  * Checks the name and descriptor for known compatibility issues and warns.
  *
  * <p>If the column names are not compatible across components or if any partition name duplicates
  * its source field name, this will warn the user.
  *
  * @param namespace a String namespace
  * @param name a String dataset name
  * @param descriptor a {@link DatasetDescriptor}
  */
 public static void checkAndWarn(String namespace, String name, DatasetDescriptor descriptor) {
   try {
     checkDatasetName(namespace, name);
     checkDescriptor(descriptor);
   } catch (IllegalArgumentException e) {
     LOG.warn(e.getMessage());
   } catch (IllegalStateException e) {
     LOG.warn(e.getMessage());
   }
 }
  @Override
  public boolean delete(String name) {
    Compatibility.checkDatasetName(name);

    // TODO: when switching off of HCatalog, this may need to be moved
    if (!exists(name)) {
      return false;
    }
    getHcat().dropTable(HiveUtils.DEFAULT_DB, name);
    return true;
  }
  @Override
  public DatasetDescriptor update(String name, DatasetDescriptor descriptor) {
    Compatibility.checkDatasetName(name);
    Compatibility.checkDescriptor(descriptor);

    if (!exists(name)) {
      throw new DatasetNotFoundException("Table not found: " + name);
    }

    Table table = getHcat().getTable(HiveUtils.DEFAULT_DB, name);
    HiveUtils.updateTableSchema(table, descriptor);
    getHcat().alterTable(table);
    return descriptor;
  }
  @Override
  public boolean exists(String name) {
    Compatibility.checkDatasetName(name);

    return getHcat().exists(HiveUtils.DEFAULT_DB, name);
  }