/** * 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); }
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); } }
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); }
/** * 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); }
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); }
/** * 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; } }
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)); }
/** * 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; } }
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); } }
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); }
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); } }
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; }
public void testMapPlan2() throws Exception { LOG.info("Beginning testMapPlan2"); populateMapPlan2(db.getTable(Warehouse.DEFAULT_DATABASE_NAME, "src")); executePlan(); fileDiff("lt100.txt", "mapplan2.out"); }
public void testMapRedPlan6() throws Exception { LOG.info("Beginning testMapPlan6"); populateMapRedPlan6(db.getTable(Warehouse.DEFAULT_DATABASE_NAME, "src")); executePlan(); fileDiff("lt100.sorted.txt", "mapredplan6.out"); } }
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"); }
public void testMapPlan1() throws Exception { LOG.info("Beginning testMapPlan1"); populateMapPlan1(db.getTable(Warehouse.DEFAULT_DATABASE_NAME, "src")); executePlan(); fileDiff("lt100.txt.deflate", "mapplan1.out"); }
public void testMapRedPlan2() throws Exception { LOG.info("Beginning testMapPlan2"); populateMapRedPlan2(db.getTable(Warehouse.DEFAULT_DATABASE_NAME, "src")); executePlan(); fileDiff("lt100.sorted.txt", "mapredplan2.out"); }
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"); }
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"); }