use of com.sap.hadoop.windowing.query2.specification.QuerySpec 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.specification.QuerySpec 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.specification.QuerySpec 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.specification.QuerySpec in project SQLWindowing by hbutani.
the class WindowSpecTranslation method translateWindowSpecOnInput.
/*
* <ol>
* <li> If wSpec points to a source WindowSpec. Validate that it is valid. If it hasn't been already translated then translate it.
* <li> Start with an empty WdwDef or a cloned WdwDef from the source WdwDef.
* <li> translate the PartitionSpec if it exists. Replace the existing PDef with this; also remove the OrderDef.
* <li> translate the OrderSpec if it exists. Replace existing OrderDef with this.
* <li> add in Partition Columns if not in OrderDef already.
* <li> translate the WindowSpec if it exists. Replace existing WdwDef with it.
* <li> If name is non-null add this def to TranslationInfo::nameToWdwDef map.
* </ol>
*/
static WindowDef translateWindowSpecOnInput(QueryDef qDef, WindowSpec wSpec, InputInfo iInfo, String inputDesc) throws WindowingException {
QuerySpec qSpec = qDef.getSpec();
WindowDef wDef;
fillInWindowSpec(qSpec, wSpec.getSourceId(), wSpec);
wDef = new WindowDef(wSpec);
PartitionSpec pSpec = wSpec.getPartition();
OrderSpec oSpec = wSpec.getOrder();
WindowFrameSpec wFrameSpec = wSpec.getWindow();
PartitionDef pDef = translatePartition(qDef, iInfo, pSpec);
OrderDef oDef = translateOrder(qDef, inputDesc, iInfo, oSpec, pDef);
WindowFrameDef wdwDef = translateWindowFrame(qDef, wFrameSpec, iInfo);
wDef.setPartDef(pDef);
wDef.setOrderDef(oDef);
wDef.setWindow(wdwDef);
return wDef;
}
use of com.sap.hadoop.windowing.query2.specification.QuerySpec in project SQLWindowing by hbutani.
the class InputTranslation method translate.
public static void translate(QueryDef qDef) throws WindowingException {
QuerySpec spec = qDef.getSpec();
/*
* validate that input chain ends in a Hive Query or TAble.
*/
if (!spec.getInput().sourcedFromHive()) {
throw new WindowingException("Translation not supported for HdfsLocation based queries");
}
EnsureTableFunctionInQuery.execute(qDef);
SlidePartitionAndOrderSpecs.execute(qDef);
TranslateInputSpecs.execute(qDef);
}
Aggregations