use of com.sap.hadoop.windowing.query2.specification.HiveTableSpec in project SQLWindowing by hbutani.
the class InputTranslation method translate.
private static HiveQueryDef translate(QueryDef qDef, HiveQuerySpec spec) throws WindowingException {
HiveQueryDef def = new HiveQueryDef();
HiveQueryExecutor hiveQryExec = qDef.getTranslationInfo().getHiveQueryExecutor();
Hive hive = qDef.getTranslationInfo().getHive();
String tableName = hiveQryExec.createTableAsQuery(spec.getHiveQuery());
HiveTableSpec tSpec = new HiveTableSpec();
tSpec.setDbName(hive.getCurrentDatabase());
tSpec.setTableName(tableName);
tSpec.setPartition(spec.getPartition());
tSpec.setOrder(spec.getOrder());
def = (HiveQueryDef) InputTranslation.translate(qDef, tSpec, (HiveTableDef) def);
return def;
}
use of com.sap.hadoop.windowing.query2.specification.HiveTableSpec in project SQLWindowing by hbutani.
the class InputTranslation method getTableAlias.
private static String getTableAlias(QueryDef qDef, int inputNum, QueryInputDef inputDef) throws WindowingException {
if (inputDef instanceof HiveTableDef) {
HiveTableDef hTbldef = (HiveTableDef) inputDef;
String db = ((HiveTableSpec) hTbldef.getSpec()).getDbName();
String tableName = ((HiveTableSpec) hTbldef.getSpec()).getTableName();
return db + "." + tableName;
} else if (inputDef instanceof TableFuncDef) {
return "ptf_" + inputNum;
}
throw new WindowingException(sprintf("Internal Error: attempt to translate %s", inputDef.getSpec()));
}
use of com.sap.hadoop.windowing.query2.specification.HiveTableSpec in project SQLWindowing by hbutani.
the class InputTranslation method translate.
private static HiveTableDef translate(QueryDef qDef, HiveTableSpec spec, HiveTableDef def) throws WindowingException {
def = def == null ? new HiveTableDef() : def;
HiveMetaStoreClient hiveMSC = qDef.getTranslationInfo().getHiveMSClient();
Hive hive = qDef.getTranslationInfo().getHive();
def.setSpec(spec);
if (spec.getDbName() == null) {
spec.setDbName(hive.getCurrentDatabase());
}
try {
Table t = hiveMSC.getTable(spec.getDbName(), spec.getTableName());
qDef.getTranslationInfo().setTbl(TranslateUtils.getHiveMetaTable(hive, t.getDbName(), def.getHiveTableSpec().getTableName()));
StorageDescriptor sd = t.getSd();
def.setInputFormatClassName(sd.getInputFormat());
def.setTableSerdeClassName(sd.getSerdeInfo().getSerializationLib());
def.setTableSerdeProps(setupSerdeProps(qDef, sd));
def.setLocation(sd.getLocation());
Deserializer serde = HiveUtils.getDeserializer(qDef.getTranslationInfo().getHiveCfg(), t);
def.setOI((StructObjectInspector) serde.getObjectInspector());
def.setSerde((SerDe) serde);
} catch (WindowingException we) {
throw we;
} catch (Exception he) {
throw new WindowingException(he);
}
return def;
}
use of com.sap.hadoop.windowing.query2.specification.HiveTableSpec in project SQLWindowing by hbutani.
the class LocalExecutor method execute.
public void execute(QueryDef qDef, WindowingShell wShell) throws WindowingException {
QueryTranslationInfo tInfo = qDef.getTranslationInfo();
HiveTableSpec hvTblSpec = qDef.getInput().getHiveTableSpec();
WindowingInput wIn = IOUtils.createTableWindowingInput(hvTblSpec.getDbName(), hvTblSpec.getTableName(), tInfo.getHiveCfg());
//Partition p = IOUtils.createPartition(partClassName, partMemSize, wIn);
PartitionsIterator partsItr = new PartitionsIterator(wIn, qDef);
while (partsItr.hasNext()) {
Partition p = partsItr.next();
Partition oP = executeChain(qDef, p);
//IOUtils.dumpPartition(oP, System.out);
executeSelectList(qDef, oP, new SysOutRS(out));
}
}
Aggregations