本文整理了Java中org.apache.hadoop.hive.ql.metadata.Hive.convertFromMetastore()
方法的一些代码示例,展示了Hive.convertFromMetastore()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hive.convertFromMetastore()
方法的具体详情如下:
包路径:org.apache.hadoop.hive.ql.metadata.Hive
类名称:Hive
方法名:convertFromMetastore
暂无
代码示例来源: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/drill
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
/**
* Get a list of Partitions by expr.
* @param tbl The table containing the partitions.
* @param expr A serialized expression for partition predicates.
* @param conf Hive config.
* @param result the resulting list of partitions
* @return whether the resulting list contains partitions which may or may not match the expr
*/
public boolean getPartitionsByExpr(Table tbl, ExprNodeGenericFuncDesc expr, HiveConf conf,
List<Partition> result) throws HiveException, TException {
assert result != null;
byte[] exprBytes = SerializationUtilities.serializeExpressionToKryo(expr);
String defaultPartitionName = HiveConf.getVar(conf, ConfVars.DEFAULTPARTITIONNAME);
List<org.apache.hadoop.hive.metastore.api.Partition> msParts =
new ArrayList<org.apache.hadoop.hive.metastore.api.Partition>();
boolean hasUnknownParts = getMSC().listPartitionsByExpr(tbl.getDbName(),
tbl.getTableName(), exprBytes, defaultPartitionName, (short)-1, msParts);
result.addAll(convertFromMetastore(tbl, msParts));
return hasUnknownParts;
}
代码示例来源:origin: apache/hive
public List<Partition> dropPartitions(String dbName, String tblName,
List<DropTableDesc.PartSpec> partSpecs, PartitionDropOptions dropOptions) throws HiveException {
try {
Table tbl = getTable(dbName, tblName);
List<org.apache.hadoop.hive.metastore.utils.ObjectPair<Integer, byte[]>> partExprs =
new ArrayList<>(partSpecs.size());
for (DropTableDesc.PartSpec partSpec : partSpecs) {
partExprs.add(new org.apache.hadoop.hive.metastore.utils.ObjectPair<>(partSpec.getPrefixLength(),
SerializationUtilities.serializeExpressionToKryo(partSpec.getPartSpec())));
}
List<org.apache.hadoop.hive.metastore.api.Partition> tParts = getMSC().dropPartitions(
dbName, tblName, partExprs, dropOptions);
return convertFromMetastore(tbl, tParts);
} catch (NoSuchObjectException e) {
throw new HiveException("Partition or table doesn't exist.", e);
} catch (Exception e) {
throw new HiveException(e.getMessage(), e);
}
}
代码示例来源:origin: apache/drill
public List<Partition> dropPartitions(String dbName, String tblName,
List<DropTableDesc.PartSpec> partSpecs, PartitionDropOptions dropOptions) throws HiveException {
try {
Table tbl = getTable(dbName, tblName);
List<ObjectPair<Integer, byte[]>> partExprs =
new ArrayList<ObjectPair<Integer,byte[]>>(partSpecs.size());
for (DropTableDesc.PartSpec partSpec : partSpecs) {
partExprs.add(new ObjectPair<Integer, byte[]>(partSpec.getPrefixLength(),
SerializationUtilities.serializeExpressionToKryo(partSpec.getPartSpec())));
}
List<org.apache.hadoop.hive.metastore.api.Partition> tParts = getMSC().dropPartitions(
dbName, tblName, partExprs, dropOptions);
return convertFromMetastore(tbl, tParts);
} catch (NoSuchObjectException e) {
throw new HiveException("Partition or table doesn't exist.", e);
} catch (Exception e) {
throw new HiveException(e.getMessage(), e);
}
}
代码示例来源:origin: apache/drill
/**
* Get a list of Partitions by expr.
* @param tbl The table containing the partitions.
* @param expr A serialized expression for partition predicates.
* @param conf Hive config.
* @param result the resulting list of partitions
* @return whether the resulting list contains partitions which may or may not match the expr
*/
public boolean getPartitionsByExpr(Table tbl, ExprNodeGenericFuncDesc expr, HiveConf conf,
List<Partition> result) throws HiveException, TException {
assert result != null;
byte[] exprBytes = SerializationUtilities.serializeExpressionToKryo(expr);
String defaultPartitionName = HiveConf.getVar(conf, ConfVars.DEFAULTPARTITIONNAME);
List<org.apache.hadoop.hive.metastore.api.Partition> msParts =
new ArrayList<org.apache.hadoop.hive.metastore.api.Partition>();
boolean hasUnknownParts = getMSC().listPartitionsByExpr(tbl.getDbName(),
tbl.getTableName(), exprBytes, defaultPartitionName, (short)-1, msParts);
result.addAll(convertFromMetastore(tbl, msParts));
return hasUnknownParts;
}
代码示例来源:origin: apache/hive
/**
* Get a list of Partitions by filter.
* @param tbl The table containing the partitions.
* @param filter A string represent partition predicates.
* @return a list of partitions satisfying the partition predicates.
* @throws HiveException
* @throws MetaException
* @throws NoSuchObjectException
* @throws TException
*/
public List<Partition> getPartitionsByFilter(Table tbl, String filter)
throws HiveException, MetaException, NoSuchObjectException, TException {
if (!tbl.isPartitioned()) {
throw new HiveException(ErrorMsg.TABLE_NOT_PARTITIONED, tbl.getTableName());
}
List<org.apache.hadoop.hive.metastore.api.Partition> tParts = getMSC().listPartitionsByFilter(
tbl.getDbName(), tbl.getTableName(), filter, (short)-1);
return convertFromMetastore(tbl, tParts);
}
代码示例来源:origin: apache/drill
/**
* Get a list of Partitions by filter.
* @param tbl The table containing the partitions.
* @param filter A string represent partition predicates.
* @return a list of partitions satisfying the partition predicates.
* @throws HiveException
* @throws MetaException
* @throws NoSuchObjectException
* @throws TException
*/
public List<Partition> getPartitionsByFilter(Table tbl, String filter)
throws HiveException, MetaException, NoSuchObjectException, TException {
if (!tbl.isPartitioned()) {
throw new HiveException(ErrorMsg.TABLE_NOT_PARTITIONED, tbl.getTableName());
}
List<org.apache.hadoop.hive.metastore.api.Partition> tParts = getMSC().listPartitionsByFilter(
tbl.getDbName(), tbl.getTableName(), filter, (short)-1);
return convertFromMetastore(tbl, tParts);
}
代码示例来源:origin: com.facebook.presto.hive/hive-apache
public List<Partition> dropPartitions(String dbName, String tblName,
List<DropTableDesc.PartSpec> partSpecs, PartitionDropOptions dropOptions) throws HiveException {
try {
Table tbl = getTable(dbName, tblName);
List<ObjectPair<Integer, byte[]>> partExprs =
new ArrayList<ObjectPair<Integer,byte[]>>(partSpecs.size());
for (DropTableDesc.PartSpec partSpec : partSpecs) {
partExprs.add(new ObjectPair<Integer, byte[]>(partSpec.getPrefixLength(),
Utilities.serializeExpressionToKryo(partSpec.getPartSpec())));
}
List<org.apache.hadoop.hive.metastore.api.Partition> tParts = getMSC().dropPartitions(
dbName, tblName, partExprs, dropOptions);
return convertFromMetastore(tbl, tParts, null);
} catch (NoSuchObjectException e) {
throw new HiveException("Partition or table doesn't exist.", e);
} catch (Exception e) {
throw new HiveException(e.getMessage(), e);
}
}
代码示例来源:origin: com.facebook.presto.hive/hive-apache
/**
* Get a list of Partitions by expr.
* @param tbl The table containing the partitions.
* @param expr A serialized expression for partition predicates.
* @param conf Hive config.
* @param result the resulting list of partitions
* @return whether the resulting list contains partitions which may or may not match the expr
*/
public boolean getPartitionsByExpr(Table tbl, ExprNodeGenericFuncDesc expr, HiveConf conf,
List<Partition> result) throws HiveException, TException {
assert result != null;
byte[] exprBytes = Utilities.serializeExpressionToKryo(expr);
String defaultPartitionName = HiveConf.getVar(conf, ConfVars.DEFAULTPARTITIONNAME);
List<org.apache.hadoop.hive.metastore.api.Partition> msParts =
new ArrayList<org.apache.hadoop.hive.metastore.api.Partition>();
boolean hasUnknownParts = getMSC().listPartitionsByExpr(tbl.getDbName(),
tbl.getTableName(), exprBytes, defaultPartitionName, (short)-1, msParts);
convertFromMetastore(tbl, msParts, result);
return hasUnknownParts;
}
代码示例来源:origin: com.facebook.presto.hive/hive-apache
/**
* Get a list of Partitions by filter.
* @param tbl The table containing the partitions.
* @param filter A string represent partition predicates.
* @return a list of partitions satisfying the partition predicates.
* @throws HiveException
* @throws MetaException
* @throws NoSuchObjectException
* @throws TException
*/
public List<Partition> getPartitionsByFilter(Table tbl, String filter)
throws HiveException, MetaException, NoSuchObjectException, TException {
if (!tbl.isPartitioned()) {
throw new HiveException(ErrorMsg.TABLE_NOT_PARTITIONED, tbl.getTableName());
}
List<org.apache.hadoop.hive.metastore.api.Partition> tParts = getMSC().listPartitionsByFilter(
tbl.getDbName(), tbl.getTableName(), filter, (short)-1);
return convertFromMetastore(tbl, tParts, null);
}
内容来源于网络,如有侵权,请联系作者删除!