Search in sources :

Example 1 with ShowPartitions

use of com.facebook.presto.sql.tree.ShowPartitions in project presto by prestodb.

the class TestSqlParser method testShowPartitions.

@Test
public void testShowPartitions() {
    assertStatement("SHOW PARTITIONS FROM t", new ShowPartitions(QualifiedName.of("t"), Optional.empty(), ImmutableList.of(), Optional.empty()));
    assertStatement("SHOW PARTITIONS FROM t WHERE x = 1", new ShowPartitions(QualifiedName.of("t"), Optional.of(new ComparisonExpression(ComparisonExpressionType.EQUAL, new Identifier("x"), new LongLiteral("1"))), ImmutableList.of(), Optional.empty()));
    assertStatement("SHOW PARTITIONS FROM t WHERE x = 1 ORDER BY y", new ShowPartitions(QualifiedName.of("t"), Optional.of(new ComparisonExpression(ComparisonExpressionType.EQUAL, new Identifier("x"), new LongLiteral("1"))), ImmutableList.of(new SortItem(new Identifier("y"), SortItem.Ordering.ASCENDING, SortItem.NullOrdering.UNDEFINED)), Optional.empty()));
    assertStatement("SHOW PARTITIONS FROM t WHERE x = 1 ORDER BY y LIMIT 10", new ShowPartitions(QualifiedName.of("t"), Optional.of(new ComparisonExpression(ComparisonExpressionType.EQUAL, new Identifier("x"), new LongLiteral("1"))), ImmutableList.of(new SortItem(new Identifier("y"), SortItem.Ordering.ASCENDING, SortItem.NullOrdering.UNDEFINED)), Optional.of("10")));
    assertStatement("SHOW PARTITIONS FROM t WHERE x = 1 ORDER BY y LIMIT ALL", new ShowPartitions(QualifiedName.of("t"), Optional.of(new ComparisonExpression(ComparisonExpressionType.EQUAL, new Identifier("x"), new LongLiteral("1"))), ImmutableList.of(new SortItem(new Identifier("y"), SortItem.Ordering.ASCENDING, SortItem.NullOrdering.UNDEFINED)), Optional.of("ALL")));
}
Also used : QuantifiedComparisonExpression(com.facebook.presto.sql.tree.QuantifiedComparisonExpression) ComparisonExpression(com.facebook.presto.sql.tree.ComparisonExpression) SortItem(com.facebook.presto.sql.tree.SortItem) Identifier(com.facebook.presto.sql.tree.Identifier) ShowPartitions(com.facebook.presto.sql.tree.ShowPartitions) LongLiteral(com.facebook.presto.sql.tree.LongLiteral) Test(org.testng.annotations.Test)

Aggregations

ComparisonExpression (com.facebook.presto.sql.tree.ComparisonExpression)1 Identifier (com.facebook.presto.sql.tree.Identifier)1 LongLiteral (com.facebook.presto.sql.tree.LongLiteral)1 QuantifiedComparisonExpression (com.facebook.presto.sql.tree.QuantifiedComparisonExpression)1 ShowPartitions (com.facebook.presto.sql.tree.ShowPartitions)1 SortItem (com.facebook.presto.sql.tree.SortItem)1 Test (org.testng.annotations.Test)1