@Override public RESULT visitWindowFunction(CONTEXT ctx, Stack<Expr> stack, WindowFunctionExpr expr) throws TajoException { stack.push(expr); RESULT result = null; for (Expr param : expr.getParams()) { result = visit(ctx, stack, param); } WindowSpec windowSpec = expr.getWindowSpec(); if (windowSpec.hasPartitionBy()) { for (Expr partitionKey : windowSpec.getPartitionKeys()) { visit(ctx, stack, partitionKey); } } if (windowSpec.hasOrderBy()) { for (Sort.SortSpec sortKey : windowSpec.getSortSpecs()) { visit(ctx, stack, sortKey.getKey()); } } if (windowSpec.hasWindowFrame()) { if (windowSpec.getWindowFrame().getStartBound().hasNumber()) { visit(ctx, stack, windowSpec.getWindowFrame().getStartBound().getNumber()); } if (windowSpec.getWindowFrame().getEndBound().hasNumber()) { visit(ctx, stack, windowSpec.getWindowFrame().getEndBound().getNumber()); } } stack.pop(); return result; }
if (windowSpec.hasWindowName()) { windowSpecReferences = new WindowSpecReferences(windowSpec.getWindowName()); } else { String [] partitionKeyReferenceNames = null; if (windowSpec.hasPartitionBy()) { partitionKeyReferenceNames = new String [windowSpec.getPartitionKeys().length]; for (int i = 0; i < windowSpec.getPartitionKeys().length; i++) { key = windowSpec.getPartitionKeys()[i]; visit(ctx, stack, key); partitionKeyReferenceNames[i] = ctx.block.namedExprsMgr.addExpr(key); if (windowSpec.hasOrderBy()) { orderKeyReferenceNames = new String[windowSpec.getSortSpecs().length]; for (int i = 0; i < windowSpec.getSortSpecs().length; i++) { key = windowSpec.getSortSpecs()[i].getKey(); visit(ctx, stack, key); String referenceName = ctx.block.namedExprsMgr.addExpr(key); if (OpType.isAggregationFunction(key.getType())) { ctx.aggExprs.add(new NamedExpr(key, referenceName)); windowSpec.getSortSpecs()[i].setKey(new ColumnReferenceExpr(referenceName));
public Object clone() throws CloneNotSupportedException { WindowSpec windowSpec = (WindowSpec) super.clone(); windowSpec.windowName = windowName; if (hasPartitionBy()) { windowSpec.partitionKeys = new Expr[windowSpec.partitionKeys.length]; for (int i = 0; i < partitionKeys.length; i++) { windowSpec.partitionKeys[i] = (Expr) partitionKeys[i].clone(); } } if (hasOrderBy()) { windowSpec.sortSpecs = new Sort.SortSpec[sortSpecs.length]; for (int i = 0; i < sortSpecs.length; i++) { windowSpec.sortSpecs[i] = (Sort.SortSpec) sortSpecs[i].clone(); } } if (hasWindowFrame()) { windowSpec.windowFrame = (WindowFrame) windowFrame.clone(); } return windowSpec; }
if (windowSpec.hasPartitionBy()) { for (int i = 0; i < windowSpec.getPartitionKeys().length; i++) { key = windowSpec.getPartitionKeys()[i]; visit(ctx, stack, key); if (windowSpec.hasOrderBy()) { sortKeys = new EvalNode[windowSpec.getSortSpecs().length]; for (int i = 0; i < windowSpec.getSortSpecs().length; i++) { key = windowSpec.getSortSpecs()[i].getKey(); sortKeys[i] = visit(ctx, stack, key); if (windowSpec.hasOrderBy()) { frame = new WindowFrame(new WindowStartBound(WindowFrameStartBoundType.UNBOUNDED_PRECEDING), new WindowEndBound(WindowFrameEndBoundType.CURRENT_ROW));
public WindowSpec buildWindowSpec(Window_specificationContext ctx) { WindowSpec windowSpec = new WindowSpec(); if (checkIfExist(ctx.window_specification_details())) { Window_specification_detailsContext windowSpecDetail = ctx.window_specification_details(); windowSpec.setWindowName(windowSpecDetail.existing_window_name().getText()); windowSpec.setPartitionKeys( buildRowValuePredicands(windowSpecDetail.window_partition_clause().row_value_predicand_list())); windowSpec.setSortSpecs( buildSortSpecs(windowSpecDetail.window_order_clause().orderby_clause().sort_specifier_list())); windowSpec.setWindowFrame(windowFrame);
if (spec.hasOrderBy()) { Sort.SortSpec [] sortSpecs = spec.getSortSpecs(); int sortNum = sortSpecs.length; String [] sortKeyRefNames = windowSpecReferenceses[winSpecIdx].getOrderKeys();
public Object clone() throws CloneNotSupportedException { WindowSpec windowSpec = (WindowSpec) super.clone(); windowSpec.windowName = windowName; if (hasPartitionBy()) { windowSpec.partitionKeys = new Expr[windowSpec.partitionKeys.length]; for (int i = 0; i < partitionKeys.length; i++) { windowSpec.partitionKeys[i] = (Expr) partitionKeys[i].clone(); } } if (hasOrderBy()) { windowSpec.sortSpecs = new Sort.SortSpec[sortSpecs.length]; for (int i = 0; i < sortSpecs.length; i++) { windowSpec.sortSpecs[i] = (Sort.SortSpec) sortSpecs[i].clone(); } } if (hasWindowFrame()) { windowSpec.windowFrame = (WindowFrame) windowFrame.clone(); } return windowSpec; }
if (windowSpec.hasPartitionBy()) { for (int i = 0; i < windowSpec.getPartitionKeys().length; i++) { key = windowSpec.getPartitionKeys()[i]; visit(ctx, stack, key); if (windowSpec.hasOrderBy()) { sortKeys = new EvalNode[windowSpec.getSortSpecs().length]; for (int i = 0; i < windowSpec.getSortSpecs().length; i++) { key = windowSpec.getSortSpecs()[i].getKey(); sortKeys[i] = visit(ctx, stack, key); if (windowSpec.hasOrderBy()) { frame = new WindowFrame(new WindowStartBound(WindowFrameStartBoundType.UNBOUNDED_PRECEDING), new WindowEndBound(WindowFrameEndBoundType.CURRENT_ROW));
public WindowSpec buildWindowSpec(Window_specificationContext ctx) { WindowSpec windowSpec = new WindowSpec(); if (checkIfExist(ctx.window_specification_details())) { Window_specification_detailsContext windowSpecDetail = ctx.window_specification_details(); windowSpec.setWindowName(windowSpecDetail.existing_window_name().getText()); windowSpec.setPartitionKeys( buildRowValuePredicands(windowSpecDetail.window_partition_clause().row_value_predicand_list())); windowSpec.setSortSpecs( buildSortSpecs(windowSpecDetail.window_order_clause().orderby_clause().sort_specifier_list())); windowSpec.setWindowFrame(windowFrame);
if (spec.hasOrderBy()) { Sort.SortSpec [] sortSpecs = spec.getSortSpecs(); int sortNum = sortSpecs.length; String [] sortKeyRefNames = windowSpecReferenceses[winSpecIdx].getOrderKeys();
@Override public RESULT visitWindowFunction(CONTEXT ctx, Stack<Expr> stack, WindowFunctionExpr expr) throws TajoException { stack.push(expr); RESULT result = null; for (Expr param : expr.getParams()) { result = visit(ctx, stack, param); } WindowSpec windowSpec = expr.getWindowSpec(); if (windowSpec.hasPartitionBy()) { for (Expr partitionKey : windowSpec.getPartitionKeys()) { visit(ctx, stack, partitionKey); } } if (windowSpec.hasOrderBy()) { for (Sort.SortSpec sortKey : windowSpec.getSortSpecs()) { visit(ctx, stack, sortKey.getKey()); } } if (windowSpec.hasWindowFrame()) { if (windowSpec.getWindowFrame().getStartBound().hasNumber()) { visit(ctx, stack, windowSpec.getWindowFrame().getStartBound().getNumber()); } if (windowSpec.getWindowFrame().getEndBound().hasNumber()) { visit(ctx, stack, windowSpec.getWindowFrame().getEndBound().getNumber()); } } stack.pop(); return result; }
if (windowSpec.hasWindowName()) { windowSpecReferences = new WindowSpecReferences(windowSpec.getWindowName()); } else { String [] partitionKeyReferenceNames = null; if (windowSpec.hasPartitionBy()) { partitionKeyReferenceNames = new String [windowSpec.getPartitionKeys().length]; for (int i = 0; i < windowSpec.getPartitionKeys().length; i++) { key = windowSpec.getPartitionKeys()[i]; visit(ctx, stack, key); partitionKeyReferenceNames[i] = ctx.block.namedExprsMgr.addExpr(key); if (windowSpec.hasOrderBy()) { orderKeyReferenceNames = new String[windowSpec.getSortSpecs().length]; for (int i = 0; i < windowSpec.getSortSpecs().length; i++) { key = windowSpec.getSortSpecs()[i].getKey(); visit(ctx, stack, key); String referenceName = ctx.block.namedExprsMgr.addExpr(key); if (OpType.isAggregationFunction(key.getType())) { ctx.aggExprs.add(new NamedExpr(key, referenceName)); windowSpec.getSortSpecs()[i].setKey(new ColumnReferenceExpr(referenceName));