org.apache.hadoop.hive.ql.metadata.Hive.getTable()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(333)

本文整理了Java中org.apache.hadoop.hive.ql.metadata.Hive.getTable()方法的一些代码示例,展示了Hive.getTable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hive.getTable()方法的具体详情如下:
包路径:org.apache.hadoop.hive.ql.metadata.Hive
类名称:Hive
方法名:getTable

Hive.getTable介绍

[英]Returns metadata for the table named tableName
[中]返回名为tableName的表的元数据

代码示例

代码示例来源:origin: apache/hive

/**
 * Returns metadata for the table named tableName
 * @param tableName the name of the table
 * @return the table metadata
 * @throws HiveException if there's an internal error or if the
 * table doesn't exist
 */
public Table getTable(final String tableName) throws HiveException {
 return this.getTable(tableName, true);
}

代码示例来源:origin: apache/hive

protected Table getTableObjectByName(String tableName, boolean throwException) throws HiveException {
 if (!tabNameToTabObject.containsKey(tableName)) {
  Table table = db.getTable(tableName, throwException);
  if (table != null) {
   tabNameToTabObject.put(tableName, table);
  }
  return table;
 } else {
  return tabNameToTabObject.get(tableName);
 }
}

代码示例来源:origin: apache/hive

protected void authorizeTable(Hive hive, String tableName, Privilege priv)
 throws AuthorizationException, HiveException {
 Table table;
 try {
  table = hive.getTable(tableName);
 } catch (InvalidTableException ite) {
  // Table itself doesn't exist in metastore, nothing to validate.
  return;
 }
 authorize(table, priv);
}

代码示例来源:origin: apache/hive

/**
 * Returns metadata for the table named tableName
 * @param tableName the name of the table
 * @param throwException controls whether an exception is thrown or a returns a null
 * @return the table metadata
 * @throws HiveException if there's an internal error or if the
 * table doesn't exist
 */
public Table getTable(final String tableName, boolean throwException) throws HiveException {
 String[] names = Utilities.getDbTableName(tableName);
 return this.getTable(names[0], names[1], throwException);
}

代码示例来源:origin: apache/drill

public void loadPartition(Path loadPath, String tableName,
  Map<String, String> partSpec, boolean replace,
  boolean inheritTableSpecs, boolean isSkewedStoreAsSubdir,
  boolean isSrcLocal, boolean isAcid, boolean hasFollowingStatsTask) throws HiveException {
 Table tbl = getTable(tableName);
 loadPartition(loadPath, tbl, partSpec, replace, inheritTableSpecs,
   isSkewedStoreAsSubdir, isSrcLocal, isAcid, hasFollowingStatsTask);
}

代码示例来源:origin: apache/hive

/**
 * Utility method that returns a table if one corresponding to the destination
 * tblDesc is found. Returns null if no such table is found.
 */
public static Table tableIfExists(ImportTableDesc tblDesc, Hive db) throws HiveException {
 try {
  return db.getTable(tblDesc.getDatabaseName(),tblDesc.getTableName());
 } catch (InvalidTableException e) {
  return null;
 }
}

代码示例来源:origin: apache/hive

public Tuple<Table> table(final String tableName, HiveConf conf) throws HiveException {
 // Column statistics won't be accurate if we are dumping only metadata
 boolean getColStats = !conf.getBoolVar(HiveConf.ConfVars.REPL_DUMP_METADATA_ONLY);
 return new Tuple<>(functionForSpec, () -> db.getTable(dbName, tableName, true, false,
     getColStats));
}

代码示例来源:origin: apache/drill

/**
 * Utility method that returns a table if one corresponding to the destination
 * tblDesc is found. Returns null if no such table is found.
 */
 private static Table tableIfExists(ImportTableDesc tblDesc, Hive db) throws HiveException {
 try {
  return db.getTable(tblDesc.getDatabaseName(),tblDesc.getTableName());
 } catch (InvalidTableException e) {
  return null;
 }
}

代码示例来源:origin: apache/drill

private boolean containsPartition(Index index, Map<String, String> partSpec)
   throws HiveException {
  String[] qualified = Utilities.getDbTableName(index.getDbName(), index.getIndexTableName());
  Table indexTable = hive.getTable(qualified[0], qualified[1]);
  List<Partition> parts = hive.getPartitions(indexTable, partSpec);
  return (parts == null || parts.size() == 0);
 }
}

代码示例来源:origin: apache/hive

public void testMapRedPlan3() throws Exception {
 LOG.info("Beginning testMapPlan3");
 populateMapRedPlan3(db.getTable(Warehouse.DEFAULT_DATABASE_NAME,
   "src"), db.getTable(Warehouse.DEFAULT_DATABASE_NAME, "src2"));
 executePlan();
 fileDiff("kv1kv2.cogroup.txt", "mapredplan3.out");
}

代码示例来源:origin: apache/hive

public static boolean shouldReplicate(NotificationEvent tableForEvent,
  ReplicationSpec replicationSpec, Hive db, HiveConf hiveConf) {
 Table table;
 try {
  table = db.getTable(tableForEvent.getDbName(), tableForEvent.getTableName());
 } catch (HiveException e) {
  LOG.info(
    "error while getting table info for" + tableForEvent.getDbName() + "." + tableForEvent
      .getTableName(), e);
  return false;
 }
 return shouldReplicate(replicationSpec, table, hiveConf);
}

代码示例来源:origin: apache/hive

public List<Partition> exchangeTablePartitions(Map<String, String> partitionSpecs,
  String sourceDb, String sourceTable, String destDb,
  String destinationTableName) throws HiveException {
 try {
  List<org.apache.hadoop.hive.metastore.api.Partition> partitions =
   getMSC().exchange_partitions(partitionSpecs, sourceDb, sourceTable, destDb,
   destinationTableName);
  return convertFromMetastore(getTable(destDb, destinationTableName), partitions);
 } catch (Exception ex) {
  LOG.error(StringUtils.stringifyException(ex));
  throw new HiveException(ex);
 }
}

代码示例来源:origin: apache/hive

private Table getTable(Hive db) throws SemanticException, HiveException {
 Table tbl = work.getTable();
 // FIXME for ctas this is still needed because location is not set sometimes
 if (tbl.getSd().getLocation() == null) {
  tbl = db.getTable(work.getFullTableName());
 }
 return tbl;
}

代码示例来源:origin: apache/hive

public void testMapPlan2() throws Exception {
 LOG.info("Beginning testMapPlan2");
 populateMapPlan2(db.getTable(Warehouse.DEFAULT_DATABASE_NAME, "src"));
 executePlan();
 fileDiff("lt100.txt", "mapplan2.out");
}

代码示例来源:origin: apache/hive

public void testMapRedPlan6() throws Exception {

  LOG.info("Beginning testMapPlan6");
  populateMapRedPlan6(db.getTable(Warehouse.DEFAULT_DATABASE_NAME,
    "src"));
  executePlan();
  fileDiff("lt100.sorted.txt", "mapredplan6.out");
 }
}

代码示例来源:origin: apache/hive

public void testMapRedPlan1() throws Exception {
 LOG.info("Beginning testMapRedPlan1");
 populateMapRedPlan1(db.getTable(Warehouse.DEFAULT_DATABASE_NAME,
   "src"));
 executePlan();
 fileDiff("kv1.val.sorted.txt", "mapredplan1.out");
}

代码示例来源:origin: apache/hive

public void testMapPlan1() throws Exception {
 LOG.info("Beginning testMapPlan1");
 populateMapPlan1(db.getTable(Warehouse.DEFAULT_DATABASE_NAME, "src"));
 executePlan();
 fileDiff("lt100.txt.deflate", "mapplan1.out");
}

代码示例来源:origin: apache/hive

public void testMapRedPlan2() throws Exception {
 LOG.info("Beginning testMapPlan2");
 populateMapRedPlan2(db.getTable(Warehouse.DEFAULT_DATABASE_NAME,
   "src"));
 executePlan();
 fileDiff("lt100.sorted.txt", "mapredplan2.out");
}

代码示例来源:origin: apache/hive

public void testMapRedPlan4() throws Exception {
 LOG.info("Beginning testMapPlan4");
 populateMapRedPlan4(db.getTable(Warehouse.DEFAULT_DATABASE_NAME,
   "src"));
 executePlan();
 fileDiff("kv1.string-sorted.txt", "mapredplan4.out");
}

代码示例来源:origin: apache/hive

public void testMapRedPlan5() throws Exception {
 LOG.info("Beginning testMapPlan5");
 populateMapRedPlan5(db.getTable(Warehouse.DEFAULT_DATABASE_NAME,
   "src"));
 executePlan();
 fileDiff("kv1.string-sorted.txt", "mapredplan5.out");
}

相关文章

微信公众号

最新文章

更多

Hive类方法