Search in sources :

Example 1 with DropBlobTable

use of io.crate.sql.tree.DropBlobTable in project crate by crate.

the class DropBlobTableAnalyzerTest method testDeletingNoExistingTableSetsNoopIfIgnoreNonExistentTablesIsSet.

@Test
public void testDeletingNoExistingTableSetsNoopIfIgnoreNonExistentTablesIsSet() throws Exception {
    when(schemas.getTableInfo(tableIdent)).thenThrow(new TableUnknownException(tableIdent));
    DropBlobTableAnalyzedStatement statement = analyzer.analyze(new DropBlobTable(table, true));
    assertThat(statement.noop(), is(true));
}
Also used : DropBlobTable(io.crate.sql.tree.DropBlobTable) TableUnknownException(io.crate.exceptions.TableUnknownException) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 2 with DropBlobTable

use of io.crate.sql.tree.DropBlobTable in project crate by crate.

the class DropBlobTableAnalyzerTest method testDeletingNonExistingTableRaisesException.

@Test
public void testDeletingNonExistingTableRaisesException() throws Exception {
    when(schemas.getTableInfo(tableIdent)).thenThrow(new TableUnknownException(tableIdent));
    expectedException.expect(TableUnknownException.class);
    expectedException.expectMessage("Table 'blob.Irrelevant' unknown");
    analyzer.analyze(new DropBlobTable(table, false));
}
Also used : DropBlobTable(io.crate.sql.tree.DropBlobTable) TableUnknownException(io.crate.exceptions.TableUnknownException) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 3 with DropBlobTable

use of io.crate.sql.tree.DropBlobTable in project crate by crate.

the class TestStatementBuilder method printStatement.

private static void printStatement(String sql) {
    println(sql.trim());
    println("");
    Statement statement = SqlParser.createStatement(sql);
    println(statement.toString());
    println("");
    // TODO: support formatting all statement types
    if (statement instanceof Query || statement instanceof CreateTable || statement instanceof CopyFrom || statement instanceof SwapTable || statement instanceof GCDanglingArtifacts || statement instanceof CreateFunction || statement instanceof CreateUser || statement instanceof GrantPrivilege || statement instanceof DenyPrivilege || statement instanceof RevokePrivilege || statement instanceof DropUser || statement instanceof DropAnalyzer || statement instanceof DropFunction || statement instanceof DropTable || statement instanceof DropBlobTable || statement instanceof DropView || statement instanceof DropRepository || statement instanceof DropSnapshot || statement instanceof Update || statement instanceof Insert || statement instanceof SetSessionAuthorizationStatement || statement instanceof Window) {
        println(SqlFormatter.formatSql(statement));
        println("");
        assertFormattedSql(statement);
    }
    println("=".repeat(60));
    println("");
}
Also used : SetSessionAuthorizationStatement(io.crate.sql.tree.SetSessionAuthorizationStatement) Window(io.crate.sql.tree.Window) Query(io.crate.sql.tree.Query) GCDanglingArtifacts(io.crate.sql.tree.GCDanglingArtifacts) SetStatement(io.crate.sql.tree.SetStatement) CommitStatement(io.crate.sql.tree.CommitStatement) DeallocateStatement(io.crate.sql.tree.DeallocateStatement) BeginStatement(io.crate.sql.tree.BeginStatement) Statement(io.crate.sql.tree.Statement) KillStatement(io.crate.sql.tree.KillStatement) SetSessionAuthorizationStatement(io.crate.sql.tree.SetSessionAuthorizationStatement) CreateFunction(io.crate.sql.tree.CreateFunction) DropView(io.crate.sql.tree.DropView) ShowCreateTable(io.crate.sql.tree.ShowCreateTable) CreateTable(io.crate.sql.tree.CreateTable) DropUser(io.crate.sql.tree.DropUser) CreateUser(io.crate.sql.tree.CreateUser) DenyPrivilege(io.crate.sql.tree.DenyPrivilege) DropRepository(io.crate.sql.tree.DropRepository) DropTable(io.crate.sql.tree.DropTable) Update(io.crate.sql.tree.Update) Insert(io.crate.sql.tree.Insert) DropAnalyzer(io.crate.sql.tree.DropAnalyzer) GrantPrivilege(io.crate.sql.tree.GrantPrivilege) DropBlobTable(io.crate.sql.tree.DropBlobTable) CopyFrom(io.crate.sql.tree.CopyFrom) DropSnapshot(io.crate.sql.tree.DropSnapshot) RevokePrivilege(io.crate.sql.tree.RevokePrivilege) DropFunction(io.crate.sql.tree.DropFunction) SwapTable(io.crate.sql.tree.SwapTable)

Aggregations

DropBlobTable (io.crate.sql.tree.DropBlobTable)3 TableUnknownException (io.crate.exceptions.TableUnknownException)2 CrateUnitTest (io.crate.test.integration.CrateUnitTest)2 Test (org.junit.Test)2 BeginStatement (io.crate.sql.tree.BeginStatement)1 CommitStatement (io.crate.sql.tree.CommitStatement)1 CopyFrom (io.crate.sql.tree.CopyFrom)1 CreateFunction (io.crate.sql.tree.CreateFunction)1 CreateTable (io.crate.sql.tree.CreateTable)1 CreateUser (io.crate.sql.tree.CreateUser)1 DeallocateStatement (io.crate.sql.tree.DeallocateStatement)1 DenyPrivilege (io.crate.sql.tree.DenyPrivilege)1 DropAnalyzer (io.crate.sql.tree.DropAnalyzer)1 DropFunction (io.crate.sql.tree.DropFunction)1 DropRepository (io.crate.sql.tree.DropRepository)1 DropSnapshot (io.crate.sql.tree.DropSnapshot)1 DropTable (io.crate.sql.tree.DropTable)1 DropUser (io.crate.sql.tree.DropUser)1 DropView (io.crate.sql.tree.DropView)1 GCDanglingArtifacts (io.crate.sql.tree.GCDanglingArtifacts)1