Search in sources :

Example 1 with QualifiedName

use of io.prestosql.sql.tree.QualifiedName in project hetu-core by openlookeng.

the class AstBuilder method visitInsertCube.

@Override
public Node visitInsertCube(SqlBaseParser.InsertCubeContext context) {
    QualifiedName cubeName = getQualifiedName(context.qualifiedName());
    Optional<Expression> optionalExpression = visitIfPresent(context.expression(), Expression.class);
    return new InsertCube(getLocation(context), cubeName, optionalExpression, false);
}
Also used : ArithmeticUnaryExpression(io.prestosql.sql.tree.ArithmeticUnaryExpression) LogicalBinaryExpression(io.prestosql.sql.tree.LogicalBinaryExpression) NotExpression(io.prestosql.sql.tree.NotExpression) ComparisonExpression(io.prestosql.sql.tree.ComparisonExpression) Expression(io.prestosql.sql.tree.Expression) ArithmeticBinaryExpression(io.prestosql.sql.tree.ArithmeticBinaryExpression) SearchedCaseExpression(io.prestosql.sql.tree.SearchedCaseExpression) DereferenceExpression(io.prestosql.sql.tree.DereferenceExpression) QuantifiedComparisonExpression(io.prestosql.sql.tree.QuantifiedComparisonExpression) NullIfExpression(io.prestosql.sql.tree.NullIfExpression) LambdaExpression(io.prestosql.sql.tree.LambdaExpression) SimpleCaseExpression(io.prestosql.sql.tree.SimpleCaseExpression) BindExpression(io.prestosql.sql.tree.BindExpression) SubqueryExpression(io.prestosql.sql.tree.SubqueryExpression) IfExpression(io.prestosql.sql.tree.IfExpression) InListExpression(io.prestosql.sql.tree.InListExpression) CoalesceExpression(io.prestosql.sql.tree.CoalesceExpression) SubscriptExpression(io.prestosql.sql.tree.SubscriptExpression) TryExpression(io.prestosql.sql.tree.TryExpression) QualifiedName(io.prestosql.sql.tree.QualifiedName) InsertCube(io.prestosql.sql.tree.InsertCube)

Example 2 with QualifiedName

use of io.prestosql.sql.tree.QualifiedName in project hetu-core by openlookeng.

the class AstBuilder method visitInsertOverwriteCube.

@Override
public Node visitInsertOverwriteCube(SqlBaseParser.InsertOverwriteCubeContext context) {
    QualifiedName cubeName = getQualifiedName(context.qualifiedName());
    Optional<Expression> optionalExpression = visitIfPresent(context.expression(), Expression.class);
    return new InsertCube(getLocation(context), cubeName, optionalExpression, true);
}
Also used : ArithmeticUnaryExpression(io.prestosql.sql.tree.ArithmeticUnaryExpression) LogicalBinaryExpression(io.prestosql.sql.tree.LogicalBinaryExpression) NotExpression(io.prestosql.sql.tree.NotExpression) ComparisonExpression(io.prestosql.sql.tree.ComparisonExpression) Expression(io.prestosql.sql.tree.Expression) ArithmeticBinaryExpression(io.prestosql.sql.tree.ArithmeticBinaryExpression) SearchedCaseExpression(io.prestosql.sql.tree.SearchedCaseExpression) DereferenceExpression(io.prestosql.sql.tree.DereferenceExpression) QuantifiedComparisonExpression(io.prestosql.sql.tree.QuantifiedComparisonExpression) NullIfExpression(io.prestosql.sql.tree.NullIfExpression) LambdaExpression(io.prestosql.sql.tree.LambdaExpression) SimpleCaseExpression(io.prestosql.sql.tree.SimpleCaseExpression) BindExpression(io.prestosql.sql.tree.BindExpression) SubqueryExpression(io.prestosql.sql.tree.SubqueryExpression) IfExpression(io.prestosql.sql.tree.IfExpression) InListExpression(io.prestosql.sql.tree.InListExpression) CoalesceExpression(io.prestosql.sql.tree.CoalesceExpression) SubscriptExpression(io.prestosql.sql.tree.SubscriptExpression) TryExpression(io.prestosql.sql.tree.TryExpression) QualifiedName(io.prestosql.sql.tree.QualifiedName) InsertCube(io.prestosql.sql.tree.InsertCube)

Example 3 with QualifiedName

use of io.prestosql.sql.tree.QualifiedName in project hetu-core by openlookeng.

the class TestSqlParser method testCreateTableAsWith.

@Test
public void testCreateTableAsWith() {
    String queryParenthesizedWith = "CREATE TABLE foo " + "AS " + "( WITH t(x) AS (VALUES 1) " + "TABLE t ) " + "WITH NO DATA";
    String queryUnparenthesizedWith = "CREATE TABLE foo " + "AS " + "WITH t(x) AS (VALUES 1) " + "TABLE t " + "WITH NO DATA";
    String queryParenthesizedWithHasAlias = "CREATE TABLE foo(a) " + "AS " + "( WITH t(x) AS (VALUES 1) " + "TABLE t ) " + "WITH NO DATA";
    String queryUnparenthesizedWithHasAlias = "CREATE TABLE foo(a) " + "AS " + "WITH t(x) AS (VALUES 1) " + "TABLE t " + "WITH NO DATA";
    QualifiedName table = QualifiedName.of("foo");
    Query query = new Query(Optional.of(new With(false, ImmutableList.of(new WithQuery(identifier("t"), query(new Values(ImmutableList.of(new LongLiteral("1")))), Optional.of(ImmutableList.of(identifier("x"))))))), new Table(QualifiedName.of("t")), Optional.empty(), Optional.empty(), Optional.empty());
    assertStatement(queryParenthesizedWith, new CreateTableAsSelect(table, query, false, ImmutableList.of(), false, Optional.empty(), Optional.empty()));
    assertStatement(queryUnparenthesizedWith, new CreateTableAsSelect(table, query, false, ImmutableList.of(), false, Optional.empty(), Optional.empty()));
    assertStatement(queryParenthesizedWithHasAlias, new CreateTableAsSelect(table, query, false, ImmutableList.of(), false, Optional.of(ImmutableList.of(new Identifier("a"))), Optional.empty()));
    assertStatement(queryUnparenthesizedWithHasAlias, new CreateTableAsSelect(table, query, false, ImmutableList.of(), false, Optional.of(ImmutableList.of(new Identifier("a"))), Optional.empty()));
}
Also used : Table(io.prestosql.sql.tree.Table) CreateTable(io.prestosql.sql.tree.CreateTable) VacuumTable(io.prestosql.sql.tree.VacuumTable) DropTable(io.prestosql.sql.tree.DropTable) RenameTable(io.prestosql.sql.tree.RenameTable) Identifier(io.prestosql.sql.tree.Identifier) QueryUtil.quotedIdentifier(io.prestosql.sql.QueryUtil.quotedIdentifier) QueryUtil.simpleQuery(io.prestosql.sql.QueryUtil.simpleQuery) Query(io.prestosql.sql.tree.Query) WithQuery(io.prestosql.sql.tree.WithQuery) LongLiteral(io.prestosql.sql.tree.LongLiteral) WithQuery(io.prestosql.sql.tree.WithQuery) QualifiedName(io.prestosql.sql.tree.QualifiedName) CreateTableAsSelect(io.prestosql.sql.tree.CreateTableAsSelect) Values(io.prestosql.sql.tree.Values) With(io.prestosql.sql.tree.With) Test(org.testng.annotations.Test)

Example 4 with QualifiedName

use of io.prestosql.sql.tree.QualifiedName in project hetu-core by openlookeng.

the class TestSqlParser method testShowStats.

@Test
public void testShowStats() {
    final String[] tableNames = { "t", "s.t", "c.s.t" };
    for (String fullName : tableNames) {
        QualifiedName qualifiedName = makeQualifiedName(fullName);
        assertStatement(format("SHOW STATS FOR %s", qualifiedName), new ShowStats(new Table(qualifiedName)));
    }
}
Also used : Table(io.prestosql.sql.tree.Table) CreateTable(io.prestosql.sql.tree.CreateTable) VacuumTable(io.prestosql.sql.tree.VacuumTable) DropTable(io.prestosql.sql.tree.DropTable) RenameTable(io.prestosql.sql.tree.RenameTable) ShowStats(io.prestosql.sql.tree.ShowStats) QualifiedName(io.prestosql.sql.tree.QualifiedName) Test(org.testng.annotations.Test)

Example 5 with QualifiedName

use of io.prestosql.sql.tree.QualifiedName in project hetu-core by openlookeng.

the class TestSqlParser method testShowStatsForQuery.

@Test
public void testShowStatsForQuery() {
    final String[] tableNames = { "t", "s.t", "c.s.t" };
    for (String fullName : tableNames) {
        QualifiedName qualifiedName = makeQualifiedName(fullName);
        assertStatement(format("SHOW STATS FOR (SELECT * FROM %s)", qualifiedName), createShowStats(qualifiedName, ImmutableList.of(new AllColumns()), Optional.empty()));
        assertStatement(format("SHOW STATS FOR (SELECT * FROM %s WHERE field > 0)", qualifiedName), createShowStats(qualifiedName, ImmutableList.of(new AllColumns()), Optional.of(new ComparisonExpression(GREATER_THAN, new Identifier("field"), new LongLiteral("0")))));
        assertStatement(format("SHOW STATS FOR (SELECT * FROM %s WHERE field > 0 or field < 0)", qualifiedName), createShowStats(qualifiedName, ImmutableList.of(new AllColumns()), Optional.of(new LogicalBinaryExpression(LogicalBinaryExpression.Operator.OR, new ComparisonExpression(GREATER_THAN, new Identifier("field"), new LongLiteral("0")), new ComparisonExpression(LESS_THAN, new Identifier("field"), new LongLiteral("0"))))));
    }
}
Also used : LogicalBinaryExpression(io.prestosql.sql.tree.LogicalBinaryExpression) ComparisonExpression(io.prestosql.sql.tree.ComparisonExpression) QuantifiedComparisonExpression(io.prestosql.sql.tree.QuantifiedComparisonExpression) Identifier(io.prestosql.sql.tree.Identifier) QueryUtil.quotedIdentifier(io.prestosql.sql.QueryUtil.quotedIdentifier) LongLiteral(io.prestosql.sql.tree.LongLiteral) QualifiedName(io.prestosql.sql.tree.QualifiedName) AllColumns(io.prestosql.sql.tree.AllColumns) Test(org.testng.annotations.Test)

Aggregations

QualifiedName (io.prestosql.sql.tree.QualifiedName)30 ComparisonExpression (io.prestosql.sql.tree.ComparisonExpression)13 Expression (io.prestosql.sql.tree.Expression)11 Test (org.testng.annotations.Test)10 Identifier (io.prestosql.sql.tree.Identifier)9 FunctionCall (io.prestosql.sql.tree.FunctionCall)8 LogicalBinaryExpression (io.prestosql.sql.tree.LogicalBinaryExpression)8 ArithmeticBinaryExpression (io.prestosql.sql.tree.ArithmeticBinaryExpression)7 CoalesceExpression (io.prestosql.sql.tree.CoalesceExpression)7 DereferenceExpression (io.prestosql.sql.tree.DereferenceExpression)7 LongLiteral (io.prestosql.sql.tree.LongLiteral)7 QuantifiedComparisonExpression (io.prestosql.sql.tree.QuantifiedComparisonExpression)7 SubqueryExpression (io.prestosql.sql.tree.SubqueryExpression)7 ArithmeticUnaryExpression (io.prestosql.sql.tree.ArithmeticUnaryExpression)6 IfExpression (io.prestosql.sql.tree.IfExpression)6 InListExpression (io.prestosql.sql.tree.InListExpression)6 NotExpression (io.prestosql.sql.tree.NotExpression)6 NullIfExpression (io.prestosql.sql.tree.NullIfExpression)6 SearchedCaseExpression (io.prestosql.sql.tree.SearchedCaseExpression)6 SimpleCaseExpression (io.prestosql.sql.tree.SimpleCaseExpression)6