Search in sources :

Example 6 with WindowDef

use of com.sap.hadoop.windowing.query2.definition.WindowDef in project SQLWindowing by hbutani.

the class WindowFunctionTranslation method translate.

public static WindowFunctionDef translate(QueryDef qDef, TableFuncDef windowTableFnDef, WindowFunctionSpec wFnSpec) throws WindowingException {
    QueryTranslationInfo tInfo = qDef.getTranslationInfo();
    InputInfo iInfo = tInfo.getInputInfo(windowTableFnDef.getInput());
    WindowFunctionDef wFnDef = new WindowFunctionDef();
    wFnDef.setSpec(wFnSpec);
    /*
		 * translate args
		 */
    ArrayList<ASTNode> args = wFnSpec.getArgs();
    if (args != null) {
        for (ASTNode expr : args) {
            ArgDef argDef = translateWindowFunctionArg(qDef, windowTableFnDef, iInfo, expr);
            wFnDef.addArg(argDef);
        }
    }
    if (RANKING_FUNCS.contains(wFnSpec.getName())) {
        setupRankingArgs(qDef, windowTableFnDef, wFnDef, wFnSpec);
    }
    WindowDef wDef = translateWindowSpec(qDef, iInfo, wFnSpec);
    wFnDef.setWindow(wDef);
    validateWindowDefForWFn(windowTableFnDef, wFnDef);
    setupEvaluator(wFnDef);
    return wFnDef;
}
Also used : InputInfo(com.sap.hadoop.windowing.query2.translate.QueryTranslationInfo.InputInfo) WindowDef(com.sap.hadoop.windowing.query2.definition.WindowDef) ASTNode(org.apache.hadoop.hive.ql.parse.ASTNode) WindowFunctionDef(com.sap.hadoop.windowing.query2.definition.WindowFunctionDef) ArgDef(com.sap.hadoop.windowing.query2.definition.ArgDef)

Aggregations

OrderDef (com.sap.hadoop.windowing.query2.definition.OrderDef)3 PartitionDef (com.sap.hadoop.windowing.query2.definition.PartitionDef)3 WindowDef (com.sap.hadoop.windowing.query2.definition.WindowDef)3 WindowingException (com.sap.hadoop.windowing.WindowingException)2 WindowFrameDef (com.sap.hadoop.windowing.query2.definition.WindowFrameDef)2 WindowSpec (com.sap.hadoop.windowing.query2.specification.WindowSpec)2 InputInfo (com.sap.hadoop.windowing.query2.translate.QueryTranslationInfo.InputInfo)2 WindowFunctionInfo (com.sap.hadoop.windowing.functions2.FunctionRegistry.WindowFunctionInfo)1 TableFunctionEvaluator (com.sap.hadoop.windowing.functions2.TableFunctionEvaluator)1 ArgDef (com.sap.hadoop.windowing.query2.definition.ArgDef)1 ColumnDef (com.sap.hadoop.windowing.query2.definition.ColumnDef)1 OrderColumnDef (com.sap.hadoop.windowing.query2.definition.OrderColumnDef)1 QueryInputDef (com.sap.hadoop.windowing.query2.definition.QueryInputDef)1 WindowFunctionDef (com.sap.hadoop.windowing.query2.definition.WindowFunctionDef)1 OrderSpec (com.sap.hadoop.windowing.query2.specification.OrderSpec)1 PartitionSpec (com.sap.hadoop.windowing.query2.specification.PartitionSpec)1 QuerySpec (com.sap.hadoop.windowing.query2.specification.QuerySpec)1 TableFuncSpec (com.sap.hadoop.windowing.query2.specification.TableFuncSpec)1 WindowFrameSpec (com.sap.hadoop.windowing.query2.specification.WindowFrameSpec)1 ASTNode (org.apache.hadoop.hive.ql.parse.ASTNode)1