use of com.sap.hadoop.windowing.query2.specification.QuerySpec in project SQLWindowing by hbutani.
the class WhereTranslation method translate.
public static void translate(QueryDef qDef) throws WindowingException {
QueryTranslationInfo tInfo = qDef.getTranslationInfo();
QuerySpec spec = qDef.getSpec();
ASTNode wExpr = spec.getWhereExpr();
if (wExpr == null)
return;
WhereDef whDef = new WhereDef();
whDef.setExpression(wExpr);
QueryInputDef iDef = qDef.getInput();
InputInfo iInfo = tInfo.getInputInfo(iDef);
ExprNodeDesc exprNode = TranslateUtils.buildExprNode(wExpr, iInfo.getTypeCheckCtx());
ExprNodeEvaluator exprEval = WindowingExprNodeEvaluatorFactory.get(tInfo, exprNode);
ObjectInspector oi = TranslateUtils.initExprNodeEvaluator(qDef, exprNode, exprEval, iInfo);
try {
ObjectInspectorConverters.getConverter(oi, PrimitiveObjectInspectorFactory.javaBooleanObjectInspector);
} catch (Throwable t) {
throw new WindowingException("Where Expr must be convertible to a boolean value", t);
}
whDef.setExprNode(exprNode);
whDef.setExprEvaluator(exprEval);
whDef.setOI(oi);
qDef.setWhere(whDef);
}
use of com.sap.hadoop.windowing.query2.specification.QuerySpec in project SQLWindowing by hbutani.
the class WindowSpecTranslation method fillInWindowSpec.
static void fillInWindowSpec(QuerySpec qSpec, String sourceId, WindowSpec destWSpec) throws WindowingException {
if (sourceId != null) {
WindowSpec sourceWSpec = qSpec.getWindowSpecs().get(sourceId);
if (sourceWSpec == null) {
throw new WindowingException(sprintf("Window Spec %s refers to an unknown source", destWSpec));
}
if (destWSpec.getPartition() == null) {
destWSpec.setPartition(sourceWSpec.getPartition());
}
if (destWSpec.getOrder() == null) {
destWSpec.setOrder(sourceWSpec.getOrder());
}
if (destWSpec.getWindow() == null) {
destWSpec.setWindow(sourceWSpec.getWindow());
}
fillInWindowSpec(qSpec, sourceWSpec.getSourceId(), destWSpec);
}
}
Aggregations