use of com.sap.hadoop.windowing.query2.definition.QueryDef in project SQLWindowing by hbutani.
the class WindowingShell method execute.
protected void execute(QueryDef q, QueryOutputPrinter outP) throws WindowingException {
QuerySpec qSpec = q.getSpec();
try {
executor.execute(q, this);
} finally {
HiveTableDef hiveTable = q.getHiveTableDef();
if (hiveTable instanceof HiveQueryDef) {
String tableName = hiveTable.getHiveTableSpec().getTableName();
hiveQryExec.dropTable(tableName);
}
}
if (qSpec.getOutput().getHiveTable() != null) {
loadToOutputTable(q);
}
if (outP != null) {
outP.printQueryOutput(q, cfg);
}
}
use of com.sap.hadoop.windowing.query2.definition.QueryDef in project SQLWindowing by hbutani.
the class WindowingShell method execute.
public void execute(String query, QueryOutputPrinter outP) throws WindowingException {
QuerySpec qSpec = parse(query);
QueryDef q = translator.translate(qSpec, this);
ArrayList<QueryDef> componentQueries;
executor.beforeComponentization(q, this);
QueryComponentizer qC = new QueryComponentizer(q, this);
componentQueries = qC.componentize();
executor.beforeExecute(q, componentQueries, this);
try {
for (QueryDef cqDef : componentQueries) {
execute(cqDef, outP);
}
} finally {
executor.afterExecute(q, componentQueries, this);
}
}
use of com.sap.hadoop.windowing.query2.definition.QueryDef in project SQLWindowing by hbutani.
the class Translator method translate.
public QueryDef translate(QuerySpec qSpec, WindowingShell wShell) throws WindowingException {
// clone the cfg
HiveConf qCfg = new HiveConf(wShell.getCfg());
QueryDef qry = new QueryDef();
qry.setSpec(qSpec);
QueryTranslationInfo transInfo = new QueryTranslationInfo();
transInfo.setHiveCfg(qCfg);
transInfo.setWshell(wShell);
try {
transInfo.setHive(Hive.get(qCfg));
transInfo.setHiveMSClient(HiveUtils.getClient(qCfg));
} catch (HiveException he) {
throw new WindowingException(he);
}
qry.setTranslationInfo(transInfo);
InputTranslation.translate(qry);
WhereTranslation.translate(qry);
OutputTranslation.translate(qry);
return qry;
}
use of com.sap.hadoop.windowing.query2.definition.QueryDef in project SQLWindowing by hbutani.
the class WindowFunctionTranslation method setupRankingArgs.
static void setupRankingArgs(QueryDef qDef, TableFuncDef windowTableFnDef, WindowFunctionDef wFnDef, WindowFunctionSpec wSpec) throws WindowingException {
if (wSpec.getArgs().size() > 0) {
throw new WindowingException("Ranking Functions can take no arguments");
}
QueryInputDef inpDef = windowTableFnDef.getInput();
InputInfo inpInfo = qDef.getTranslationInfo().getInputInfo(inpDef);
OrderDef oDef = getTableFuncOrderDef(windowTableFnDef);
ArrayList<OrderColumnDef> oCols = oDef.getColumns();
for (OrderColumnDef oCol : oCols) {
wFnDef.addArg(TranslateUtils.buildArgDef(qDef, inpInfo, oCol.getExpression()));
}
}
use of com.sap.hadoop.windowing.query2.definition.QueryDef in project SQLWindowing by hbutani.
the class WindowFunctionTranslation method addInputColumnsToList.
public static void addInputColumnsToList(QueryDef qDef, TableFuncDef windowTableFnDef, ArrayList<String> fieldNames, ArrayList<ObjectInspector> fieldOIs) {
QueryTranslationInfo tInfo = qDef.getTranslationInfo();
InputInfo iInfo = tInfo.getInputInfo(windowTableFnDef.getInput());
StructObjectInspector OI = (StructObjectInspector) iInfo.getOI();
for (StructField f : OI.getAllStructFieldRefs()) {
fieldNames.add(f.getFieldName());
fieldOIs.add(f.getFieldObjectInspector());
}
}
Aggregations