use of com.sap.hadoop.windowing.query2.definition.QueryDef in project SQLWindowing by hbutani.
the class WindowSpecTranslation method translatePartition.
static PartitionDef translatePartition(QueryDef qDef, InputInfo iInfo, PartitionSpec spec) throws WindowingException {
if (spec == null || spec.getColumns() == null || spec.getColumns().size() == 0)
return null;
PartitionDef pDef = new PartitionDef(spec);
for (ColumnSpec colSpec : spec.getColumns()) {
ColumnDef cDef = translatePartitionColumn(qDef, iInfo, colSpec);
pDef.addColumn(cDef);
}
return pDef;
}
use of com.sap.hadoop.windowing.query2.definition.QueryDef in project SQLWindowing by hbutani.
the class WindowSpecTranslation method translateWindowFrame.
static WindowFrameDef translateWindowFrame(QueryDef qDef, WindowFrameSpec wfSpec, InputInfo iInfo) throws WindowingException {
if (wfSpec == null) {
return null;
}
BoundarySpec s = wfSpec.getStart();
BoundarySpec e = wfSpec.getEnd();
WindowFrameDef wfDef = new WindowFrameDef(wfSpec);
wfDef.setStart(translateBoundary(qDef, s, iInfo));
wfDef.setEnd(translateBoundary(qDef, e, iInfo));
int cmp = s.compareTo(e);
if (cmp > 0) {
throw new WindowingException(sprintf("Window range invalid, start boundary is greater than end boundary: %s", wfSpec));
}
return wfDef;
}
use of com.sap.hadoop.windowing.query2.definition.QueryDef in project SQLWindowing by hbutani.
the class Executor method executeChain.
/**
* For all the table functions to be applied to the input
* hive table or query, push them on a stack.
* For each table function popped out of the stack,
* execute the function on the input partition
* and return an output partition.
* @param qDef
* @param part
* @return
* @throws WindowingException
*/
public static Partition executeChain(QueryDef qDef, Partition part) throws WindowingException {
Stack<TableFuncDef> fnDefs = new Stack<TableFuncDef>();
QueryInputDef iDef = qDef.getInput();
while (true) {
if (iDef instanceof TableFuncDef) {
fnDefs.push((TableFuncDef) iDef);
iDef = ((TableFuncDef) iDef).getInput();
} else {
break;
}
}
TableFuncDef currFnDef;
while (!fnDefs.isEmpty()) {
currFnDef = fnDefs.pop();
part = currFnDef.getFunction().execute(part);
}
return part;
}
use of com.sap.hadoop.windowing.query2.definition.QueryDef in project SQLWindowing by hbutani.
the class RuntimeUtils method connectLeadLagFunctionsToPartition.
public static void connectLeadLagFunctionsToPartition(QueryDef qDef, PartitionIterator<Object> pItr) throws WindowingException {
QueryTranslationInfo tInfo = qDef.getTranslationInfo();
List<ExprNodeGenericFuncDesc> llFnDescs = tInfo.getLLInfo().getLeadLagExprs();
if (llFnDescs == null)
return;
for (ExprNodeGenericFuncDesc llFnDesc : llFnDescs) {
GenericUDFLeadLag llFn = (GenericUDFLeadLag) llFnDesc.getGenericUDF();
llFn.setpItr(pItr);
}
}
use of com.sap.hadoop.windowing.query2.definition.QueryDef in project SQLWindowing by hbutani.
the class RuntimeUtils method getFirstTableFunction.
/**
* Iterate the list of the query input definitions in reverse order
* Return the first table function definition in the chain.
* This table function is the first one to be executed on the
* input hive table.
* @param qDef
* @return
*/
public static TableFuncDef getFirstTableFunction(QueryDef qDef) {
TableFuncDef tabDef = null;
Iterator<QueryInputDef> it = TranslateUtils.iterateInputDefs(qDef, true);
while (it.hasNext()) {
QueryInputDef qIn = it.next();
if (qIn instanceof TableFuncDef) {
tabDef = (TableFuncDef) qIn;
break;
}
}
return tabDef;
}
Aggregations