Search in sources :

Example 6 with SqlQueryManager

use of io.prestosql.execution.SqlQueryManager in project hetu-core by openlookeng.

the class TestCachedSqlQueryExecution method testCreateTableRepeated.

@Test
public void testCreateTableRepeated() throws Exception {
    setupWithExecutionPlanCacheEnabled(DEFAULT_SESSION);
    TestingMetadata metadata = new TestingMetadata();
    queryRunner.installPlugin(new TestPlugin(metadata));
    queryRunner.createCatalog("test", "test");
    SqlQueryManager manager = (SqlQueryManager) queryRunner.getCoordinator().getQueryManager();
    String query1 = "CREATE TABLE orders AS SELECT * FROM tpch.tiny.orders";
    String query3 = "INSERT INTO orders SELECT * FROM orders";
    String query4 = "INSERT INTO orders SELECT * FROM test.default.orders";
    Plan plan1 = getPlan(query1, manager);
    metadata.dropTable(DEFAULT_SESSION.toConnectorSession(), metadata.getTableHandle(DEFAULT_SESSION.toConnectorSession(), new SchemaTableName("default", "orders")));
    Plan plan2 = getPlan(query1, manager);
    Plan plan3 = getPlan(query3, manager);
    Plan plan4 = getPlan(query4, manager);
    assertNotNull(plan1);
    assertNotNull(plan2);
    assertNotNull(plan3);
    assertNotNull(plan4);
    // Create statements should not be cached
    assertNotSame(plan1.getStatsAndCosts(), plan2.getStatsAndCosts());
    // Statement does not include fully qualified name
    assertNotSame(plan3.getStatsAndCosts(), plan4.getStatsAndCosts());
}
Also used : TestingMetadata(io.prestosql.testing.TestingMetadata) Plan(io.prestosql.sql.planner.Plan) SqlQueryManager(io.prestosql.execution.SqlQueryManager) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest)

Example 7 with SqlQueryManager

use of io.prestosql.execution.SqlQueryManager in project hetu-core by openlookeng.

the class TestCachedSqlQueryExecution method testQueriesWithCurrentTimeFunction.

@Test
public void testQueriesWithCurrentTimeFunction() throws Exception {
    setupWithExecutionPlanCacheEnabled(DEFAULT_SESSION);
    TestingMetadata metadata = new TestingMetadata();
    queryRunner.installPlugin(new TestPlugin(metadata));
    queryRunner.createCatalog("test", "test");
    SqlQueryManager manager = (SqlQueryManager) queryRunner.getCoordinator().getQueryManager();
    String query1 = "SELECT CURRENT_TIME";
    Plan plan1 = getPlan(query1, manager);
    Plan plan2 = getPlan(query1, manager);
    assertNotNull(plan1);
    assertNotNull(plan2);
    // Should not have the same plan
    assertNotSame(plan1.getStatsAndCosts(), plan2.getStatsAndCosts());
    MaterializedResult rows1 = queryRunner.execute(DEFAULT_SESSION, query1);
    MaterializedResult rows2 = queryRunner.execute(DEFAULT_SESSION, query1);
    assertEquals(rows1.getRowCount(), rows2.getRowCount());
    MaterializedRow row1 = Iterables.getOnlyElement(rows1);
    MaterializedRow row2 = Iterables.getOnlyElement(rows2);
    assertEquals(row1.getFieldCount(), row2.getFieldCount());
    assertNotSame(row1.getFields(), row2.getFields());
}
Also used : TestingMetadata(io.prestosql.testing.TestingMetadata) Plan(io.prestosql.sql.planner.Plan) MaterializedResult(io.prestosql.testing.MaterializedResult) SqlQueryManager(io.prestosql.execution.SqlQueryManager) MaterializedRow(io.prestosql.testing.MaterializedRow) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest)

Example 8 with SqlQueryManager

use of io.prestosql.execution.SqlQueryManager in project hetu-core by openlookeng.

the class TestCachedSqlQueryExecution method testExecutionPlanCacheSessionDisabled.

@Test
public void testExecutionPlanCacheSessionDisabled() throws Exception {
    // enabled globally
    setupWithExecutionPlanCacheEnabled(CACHING_DISABLED_SESSION);
    SqlQueryManager manager = (SqlQueryManager) queryRunner.getCoordinator().getQueryManager();
    Plan plan1 = getPlan(TEST_SQL, manager);
    Plan plan2 = getPlan(TEST_SQL, manager);
    assertNotSame(plan1.getStatsAndCosts(), plan2.getStatsAndCosts());
}
Also used : Plan(io.prestosql.sql.planner.Plan) SqlQueryManager(io.prestosql.execution.SqlQueryManager) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest)

Example 9 with SqlQueryManager

use of io.prestosql.execution.SqlQueryManager in project hetu-core by openlookeng.

the class TestCachedSqlQueryExecution method testQueriesWithFunctionsOnChangedTable.

@Test
public void testQueriesWithFunctionsOnChangedTable() throws Exception {
    setupWithExecutionPlanCacheEnabled(DEFAULT_SESSION);
    TestingMetadata metadata = new TestingMetadata();
    queryRunner.installPlugin(new TestPlugin(metadata));
    queryRunner.createCatalog("test", "test");
    SqlQueryManager manager = (SqlQueryManager) queryRunner.getCoordinator().getQueryManager();
    String query1 = "CREATE TABLE orders AS SELECT ORDERKEY, CUSTKEY, TOTALPRICE FROM tpch.tiny.orders";
    String query2 = "INSERT INTO orders SELECT * FROM orders";
    String query3 = "SELECT SUM(TOTALPRICE) FROM orders WHERE TOTALPRICE > 1";
    String query4 = "CREATE TABLE orders AS SELECT ORDERKEY, CUSTKEY, cast(TOTALPRICE as integer) AS TOTALPRICE, COMMENT FROM tpch.tiny.orders";
    Plan plan1 = getPlan(query1, manager);
    Plan plan2 = getPlan(query2, manager);
    Plan plan3 = getPlan(query3, manager);
    metadata.dropTable(DEFAULT_SESSION.toConnectorSession(), metadata.getTableHandle(DEFAULT_SESSION.toConnectorSession(), new SchemaTableName("default", "orders")));
    Plan plan4 = getPlan(query4, manager);
    Plan plan5 = getPlan(query3, manager);
    assertNotNull(plan1);
    assertNotNull(plan2);
    assertNotNull(plan3);
    assertNotNull(plan4);
    // Predicate types are different
    assertNotSame(plan3.getStatsAndCosts(), plan5.getStatsAndCosts());
}
Also used : TestingMetadata(io.prestosql.testing.TestingMetadata) Plan(io.prestosql.sql.planner.Plan) SqlQueryManager(io.prestosql.execution.SqlQueryManager) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest)

Example 10 with SqlQueryManager

use of io.prestosql.execution.SqlQueryManager in project hetu-core by openlookeng.

the class TestCachedSqlQueryExecution method testAlteredColumnType.

@Test
public void testAlteredColumnType() throws Exception {
    setupWithExecutionPlanCacheEnabled(DEFAULT_SESSION);
    TestingMetadata metadata = new TestingMetadata();
    queryRunner.installPlugin(new TestPlugin(metadata));
    queryRunner.createCatalog("test", "test");
    SqlQueryManager manager = (SqlQueryManager) queryRunner.getCoordinator().getQueryManager();
    String query1 = "CREATE TABLE orders AS SELECT ORDERKEY, CUSTKEY, TOTALPRICE, COMMENT FROM tpch.tiny.orders";
    String query2 = "INSERT INTO orders SELECT * FROM orders";
    String query3 = "SELECT ORDERKEY, TOTALPRICE FROM orders";
    Plan plan1 = getPlan(query1, manager);
    Plan plan2 = getPlan(query2, manager);
    Plan plan3 = getPlan(query3, manager);
    metadata.dropTable(DEFAULT_SESSION.toConnectorSession(), metadata.getTableHandle(DEFAULT_SESSION.toConnectorSession(), new SchemaTableName("default", "orders")));
    String query4 = "CREATE TABLE orders AS SELECT ORDERKEY, CUSTKEY, cast(TOTALPRICE as integer) AS TOTALPRICE, COMMENT FROM tpch.tiny.orders";
    Plan plan4 = getPlan(query4, manager);
    Plan plan5 = getPlan(query3, manager);
    assertNotNull(plan1);
    assertNotNull(plan2);
    assertNotNull(plan3);
    assertNotNull(plan4);
    assertNotNull(plan5);
    // new plan should not be the same as the old plan
    assertNotSame(plan3.getStatsAndCosts(), plan5.getStatsAndCosts());
}
Also used : TestingMetadata(io.prestosql.testing.TestingMetadata) Plan(io.prestosql.sql.planner.Plan) SqlQueryManager(io.prestosql.execution.SqlQueryManager) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest)

Aggregations

SqlQueryManager (io.prestosql.execution.SqlQueryManager)19 Plan (io.prestosql.sql.planner.Plan)19 AfterTest (org.testng.annotations.AfterTest)19 Test (org.testng.annotations.Test)19 TestingMetadata (io.prestosql.testing.TestingMetadata)10 SchemaTableName (io.prestosql.spi.connector.SchemaTableName)6 MaterializedResult (io.prestosql.testing.MaterializedResult)4 MaterializedRow (io.prestosql.testing.MaterializedRow)4