normalizedExprList[i] = normalizer.normalize(context, sortSpecs[i].getKey());
throw new IllegalStateException("Unexpected State: " + StringUtils.join(sortSpecs)); annotatedSortSpecs[i] = new SortSpec(column, sortSpecs[i].isAscending(), sortSpecs[i].isNullsFirst());
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; }
throw new IllegalStateException("Unexpected State: " + StringUtils.join(sortSpecs)); annotatedSortSpecs[i] = new SortSpec(column, sortSpecs[i].isAscending(), sortSpecs[i].isNullsFirst());
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);
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);
normalizedExprList[i] = normalizer.normalize(context, sortSpecs[i].getKey());
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));
normalizedExprList[i] = normalizer.normalize(context, sortSpecs[i].getKey());
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));
int i = 0; for (SortSpec sortSpec : sortSpecs) { targets[i++] = new NamedExpr(sortSpec.getKey());
int i = 0; for (SortSpec sortSpec : sortSpecs) { targets.add(new NamedExpr(sortSpec.getKey()));
normalizedExprList[i] = normalizer.normalize(context, sortSpecs[i].getKey());
@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; }
@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; }
@Test public void testEquals() throws Exception { Expr expr = new BinaryOperator(OpType.LessThan, new LiteralValue("1", LiteralType.Unsigned_Integer), new LiteralValue("2", LiteralType.Unsigned_Integer)); Relation relation = new Relation("employee"); Selection selection = new Selection(expr); selection.setChild(relation); Aggregation aggregation = new Aggregation(); aggregation.setTargets(new NamedExpr[]{ new NamedExpr(new ColumnReferenceExpr("col1")) } ); aggregation.setChild(selection); Sort.SortSpec spec = new Sort.SortSpec(new ColumnReferenceExpr("col2")); Sort sort = new Sort(new Sort.SortSpec[]{spec}); sort.setChild(aggregation); assertEquals(sort, sort); Expr different = generateOneExpr(); assertFalse(sort.equals(different)); }
public Sort.SortSpec[] buildSortSpecs(Sort_specifier_listContext context) { int size = context.sort_specifier().size(); Sort.SortSpec specs[] = new Sort.SortSpec[size]; for (int i = 0; i < size; i++) { Sort_specifierContext specContext = context.sort_specifier(i); Expr sortKeyExpr = visitRow_value_predicand(specContext.key); specs[i] = new Sort.SortSpec(sortKeyExpr); if (specContext.order_specification() != null) { if (specContext.order.DESC() != null) { specs[i].setDescending(); } } if (specContext.null_ordering() != null) { if (specContext.null_ordering().FIRST() != null) { specs[i].setNullsFirst(); } else if (specContext.null_ordering().LAST() != null) { specs[i].setNullsLast(); } } } return specs; }
@Test public void testJson2() { Expr expr = new BinaryOperator(OpType.LessThan, new LiteralValue("1", LiteralType.Unsigned_Integer), new LiteralValue("2", LiteralType.Unsigned_Integer)); Relation relation = new Relation("employee"); Selection selection = new Selection(expr); selection.setChild(relation); Aggregation aggregation = new Aggregation(); aggregation.setTargets(new NamedExpr[]{ new NamedExpr(new ColumnReferenceExpr("col1")) } ); aggregation.setChild(selection); Sort.SortSpec spec = new Sort.SortSpec(new ColumnReferenceExpr("col2")); Sort sort = new Sort(new Sort.SortSpec[]{spec}); sort.setChild(aggregation); String json = sort.toJson(); Expr fromJson = JsonHelper.fromJson(json, Expr.class); assertEquals(sort, fromJson); } }
public Sort.SortSpec[] buildSortSpecs(Sort_specifier_listContext context) { int size = context.sort_specifier().size(); Sort.SortSpec specs[] = new Sort.SortSpec[size]; for (int i = 0; i < size; i++) { Sort_specifierContext specContext = context.sort_specifier(i); Expr sortKeyExpr = visitRow_value_predicand(specContext.key); specs[i] = new Sort.SortSpec(sortKeyExpr); if (specContext.order_specification() != null) { if (specContext.order.DESC() != null) { specs[i].setDescending(); } } if (specContext.null_ordering() != null) { if (specContext.null_ordering().FIRST() != null) { specs[i].setNullsFirst(); } else if (specContext.null_ordering().LAST() != null) { specs[i].setNullsLast(); } } } return specs; }
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; }