public static SortItem ascending(String name) { return new SortItem(identifier(name), SortItem.Ordering.ASCENDING, SortItem.NullOrdering.UNDEFINED); }
public static SortItem ascending(String name) { return new SortItem(identifier(name), SortItem.Ordering.ASCENDING, SortItem.NullOrdering.UNDEFINED); }
@Override public Node visitSortItem(SqlBaseParser.SortItemContext context) { return new SortItem( getLocation(context), (Expression) visit(context.expression()), Optional.ofNullable(context.ordering) .map(AstBuilder::getOrderingType) .orElse(SortItem.Ordering.ASCENDING), Optional.ofNullable(context.nullOrdering) .map(AstBuilder::getNullOrderingType) .orElse(SortItem.NullOrdering.UNDEFINED)); }
@Override public Node visitSortItem(SqlBaseParser.SortItemContext context) { return new SortItem( getLocation(context), (Expression) visit(context.expression()), Optional.ofNullable(context.ordering) .map(AstBuilder::getOrderingType) .orElse(SortItem.Ordering.ASCENDING), Optional.ofNullable(context.nullOrdering) .map(AstBuilder::getNullOrderingType) .orElse(SortItem.NullOrdering.UNDEFINED)); }
aliased(new Values(rows.build()), "functions", ImmutableList.copyOf(columns.keySet())), ordering( new SortItem( functionCall("lower", identifier("function_name")), SortItem.Ordering.ASCENDING,
aliased(new Values(rows.build()), "functions", ImmutableList.copyOf(columns.keySet())), ordering( new SortItem( functionCall("lower", identifier("function_name")), SortItem.Ordering.ASCENDING,
public FunctionCall getExpectedValue(SymbolAliases aliases) { List<Expression> symbolReferences = toSymbolReferences(args, aliases); if (isWindowFunction) { return new ExpectedWindowFunctionCall(symbolReferences); } Optional<OrderBy> orderByClause = Optional.empty(); if (!orderBy.isEmpty()) { orderByClause = Optional.of(new OrderBy(orderBy.stream() .map(item -> new SortItem( Symbol.from(aliases.get(item.getField())).toSymbolReference(), item.getOrdering(), item.getNullOrdering())) .collect(Collectors.toList()))); } return new FunctionCall(name, Optional.empty(), Optional.empty(), orderByClause, distinct, symbolReferences); }
public FunctionCall getExpectedValue(SymbolAliases aliases) { List<Expression> symbolReferences = toSymbolReferences(args, aliases); if (isWindowFunction) { return new ExpectedWindowFunctionCall(symbolReferences); } Optional<OrderBy> orderByClause = Optional.empty(); if (!orderBy.isEmpty()) { orderByClause = Optional.of(new OrderBy(orderBy.stream() .map(item -> new SortItem( Symbol.from(aliases.get(item.getField())).toSymbolReference(), item.getOrdering(), item.getNullOrdering())) .collect(Collectors.toList()))); } return new FunctionCall(name, Optional.empty(), Optional.empty(), orderByClause, distinct, symbolReferences); }
@Test public void testSelectWithOrderBy() { assertStatement("SELECT * FROM table1 ORDER BY a", new Query( Optional.empty(), new QuerySpecification( selectList(new AllColumns()), Optional.of(new Table(QualifiedName.of("table1"))), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(new OrderBy(ImmutableList.of(new SortItem( new Identifier("a"), ASCENDING, UNDEFINED)))), Optional.empty()), Optional.empty(), Optional.empty())); }
Optional.empty(), Optional.empty(), Optional.of(new OrderBy(ImmutableList.of(new SortItem(identifier("x"), DESCENDING, UNDEFINED)))), false, ImmutableList.of(identifier("x")))); Optional.empty(), Optional.empty(), Optional.of(new OrderBy(ImmutableList.of(new SortItem(new DereferenceExpression(new Identifier("t"), identifier("y")), ASCENDING, UNDEFINED)))), false, ImmutableList.of(new Identifier("x")))),