Search in sources :

Example 1 with ResultWithQueryId

use of io.prestosql.tests.ResultWithQueryId in project hetu-core by openlookeng.

the class TestMemorySmoke method testSemiJoinDynamicFilteringNone.

@Test
public void testSemiJoinDynamicFilteringNone() {
    final long buildSideRowsCount = 15_000L;
    Session session = Session.builder(getSession()).setSystemProperty(ENABLE_DYNAMIC_FILTERING, "true").setSystemProperty(JOIN_DISTRIBUTION_TYPE, FeaturesConfig.JoinDistributionType.BROADCAST.name()).build();
    DistributedQueryRunner runner = (DistributedQueryRunner) getQueryRunner();
    ResultWithQueryId<MaterializedResult> result = runner.executeWithQueryId(session, "SELECT * FROM lineitem WHERE orderkey IN (SELECT orderkey from orders WHERE totalprice < 0)");
    assertEquals(result.getResult().getRowCount(), 0);
    QueryStats stats = runner.getCoordinator().getQueryManager().getFullQueryInfo(result.getQueryId()).getQueryStats();
    Set rowsRead = stats.getOperatorSummaries().stream().filter(summary -> summary.getOperatorType().equals("ScanFilterAndProjectOperator")).map(summary -> summary.getInputPositions()).collect(toImmutableSet());
    assertEquals(rowsRead, ImmutableSet.of(0L, buildSideRowsCount));
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) ResultWithQueryId(io.prestosql.tests.ResultWithQueryId) Language(org.intellij.lang.annotations.Language) Set(java.util.Set) Test(org.testng.annotations.Test) QueryStats(io.prestosql.execution.QueryStats) MaterializedRow(io.prestosql.testing.MaterializedRow) MaterializedResult(io.prestosql.testing.MaterializedResult) String.format(java.lang.String.format) QualifiedObjectName(io.prestosql.spi.connector.QualifiedObjectName) AbstractTestQueryFramework(io.prestosql.tests.AbstractTestQueryFramework) Assert.assertEquals(io.prestosql.testing.assertions.Assert.assertEquals) List(java.util.List) ENABLE_DYNAMIC_FILTERING(io.prestosql.SystemSessionProperties.ENABLE_DYNAMIC_FILTERING) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) Session(io.prestosql.Session) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) Assert.assertTrue(org.testng.Assert.assertTrue) JOIN_DISTRIBUTION_TYPE(io.prestosql.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) QueryStats(io.prestosql.execution.QueryStats) MaterializedResult(io.prestosql.testing.MaterializedResult) Session(io.prestosql.Session) Test(org.testng.annotations.Test)

Example 2 with ResultWithQueryId

use of io.prestosql.tests.ResultWithQueryId in project hetu-core by openlookeng.

the class TestMemorySmoke method testJoinDynamicFilteringSingleValue.

@Test
public void testJoinDynamicFilteringSingleValue() {
    final long buildSideRowsCount = 15_000L;
    assertQueryResult("SELECT COUNT() FROM orders", buildSideRowsCount);
    assertQueryResult("SELECT COUNT() FROM orders WHERE comment = 'nstructions sleep furiously among '", 1L);
    assertQueryResult("SELECT orderkey FROM orders WHERE comment = 'nstructions sleep furiously among '", 1L);
    assertQueryResult("SELECT COUNT() FROM lineitem WHERE orderkey = 1", 6L);
    Session session = Session.builder(getSession()).setSystemProperty(ENABLE_DYNAMIC_FILTERING, "true").setSystemProperty(JOIN_DISTRIBUTION_TYPE, FeaturesConfig.JoinDistributionType.BROADCAST.name()).build();
    DistributedQueryRunner runner = (DistributedQueryRunner) getQueryRunner();
    ResultWithQueryId<MaterializedResult> result = runner.executeWithQueryId(session, "SELECT * FROM lineitem JOIN orders " + "ON lineitem.orderkey = orders.orderkey AND orders.comment = 'nstructions sleep furiously among '");
    assertEquals(result.getResult().getRowCount(), 6);
    // Probe-side is dynamically filtered:
    // Note: because the global dynamic filter is not applied in the memory connector, we have changed the assert value for this test
    QueryStats stats = runner.getCoordinator().getQueryManager().getFullQueryInfo(result.getQueryId()).getQueryStats();
    Set rowsRead = stats.getOperatorSummaries().stream().filter(summary -> summary.getOperatorType().equals("ScanFilterAndProjectOperator")).map(summary -> summary.getInputPositions()).collect(toImmutableSet());
    assertEquals(rowsRead, ImmutableSet.of(6L, buildSideRowsCount));
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) ResultWithQueryId(io.prestosql.tests.ResultWithQueryId) Language(org.intellij.lang.annotations.Language) Set(java.util.Set) Test(org.testng.annotations.Test) QueryStats(io.prestosql.execution.QueryStats) MaterializedRow(io.prestosql.testing.MaterializedRow) MaterializedResult(io.prestosql.testing.MaterializedResult) String.format(java.lang.String.format) QualifiedObjectName(io.prestosql.spi.connector.QualifiedObjectName) AbstractTestQueryFramework(io.prestosql.tests.AbstractTestQueryFramework) Assert.assertEquals(io.prestosql.testing.assertions.Assert.assertEquals) List(java.util.List) ENABLE_DYNAMIC_FILTERING(io.prestosql.SystemSessionProperties.ENABLE_DYNAMIC_FILTERING) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) Session(io.prestosql.Session) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) Assert.assertTrue(org.testng.Assert.assertTrue) JOIN_DISTRIBUTION_TYPE(io.prestosql.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) QueryStats(io.prestosql.execution.QueryStats) MaterializedResult(io.prestosql.testing.MaterializedResult) Session(io.prestosql.Session) Test(org.testng.annotations.Test)

Example 3 with ResultWithQueryId

use of io.prestosql.tests.ResultWithQueryId in project hetu-core by openlookeng.

the class TestMemorySmoke method testSemiJoinDynamicFilteringSingleValue.

@Test
public void testSemiJoinDynamicFilteringSingleValue() {
    final long buildSideRowsCount = 15_000L;
    Session session = Session.builder(getSession()).setSystemProperty(ENABLE_DYNAMIC_FILTERING, "true").setSystemProperty(JOIN_DISTRIBUTION_TYPE, FeaturesConfig.JoinDistributionType.BROADCAST.name()).build();
    DistributedQueryRunner runner = (DistributedQueryRunner) getQueryRunner();
    ResultWithQueryId<MaterializedResult> result = runner.executeWithQueryId(session, "SELECT * FROM lineitem WHERE orderkey IN (SELECT orderkey from orders WHERE orders.comment = 'nstructions sleep furiously among ')");
    assertEquals(result.getResult().getRowCount(), 6);
    QueryStats stats = runner.getCoordinator().getQueryManager().getFullQueryInfo(result.getQueryId()).getQueryStats();
    Set rowsRead = stats.getOperatorSummaries().stream().filter(summary -> summary.getOperatorType().equals("ScanFilterAndProjectOperator")).map(summary -> summary.getInputPositions()).collect(toImmutableSet());
    assertEquals(rowsRead, ImmutableSet.of(6L, buildSideRowsCount));
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) ResultWithQueryId(io.prestosql.tests.ResultWithQueryId) Language(org.intellij.lang.annotations.Language) Set(java.util.Set) Test(org.testng.annotations.Test) QueryStats(io.prestosql.execution.QueryStats) MaterializedRow(io.prestosql.testing.MaterializedRow) MaterializedResult(io.prestosql.testing.MaterializedResult) String.format(java.lang.String.format) QualifiedObjectName(io.prestosql.spi.connector.QualifiedObjectName) AbstractTestQueryFramework(io.prestosql.tests.AbstractTestQueryFramework) Assert.assertEquals(io.prestosql.testing.assertions.Assert.assertEquals) List(java.util.List) ENABLE_DYNAMIC_FILTERING(io.prestosql.SystemSessionProperties.ENABLE_DYNAMIC_FILTERING) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) Session(io.prestosql.Session) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) Assert.assertTrue(org.testng.Assert.assertTrue) JOIN_DISTRIBUTION_TYPE(io.prestosql.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) QueryStats(io.prestosql.execution.QueryStats) MaterializedResult(io.prestosql.testing.MaterializedResult) Session(io.prestosql.Session) Test(org.testng.annotations.Test)

Example 4 with ResultWithQueryId

use of io.prestosql.tests.ResultWithQueryId in project hetu-core by openlookeng.

the class TestMemorySmoke method testJoinDynamicFilteringNone.

@Test
public void testJoinDynamicFilteringNone() {
    final long buildSideRowsCount = 15_000L;
    assertQueryResult("SELECT COUNT() FROM orders", buildSideRowsCount);
    assertQueryResult("SELECT COUNT() FROM orders WHERE totalprice < 0", 0L);
    Session session = Session.builder(getSession()).setSystemProperty(ENABLE_DYNAMIC_FILTERING, "true").setSystemProperty(JOIN_DISTRIBUTION_TYPE, FeaturesConfig.JoinDistributionType.BROADCAST.name()).build();
    DistributedQueryRunner runner = (DistributedQueryRunner) getQueryRunner();
    ResultWithQueryId<MaterializedResult> result = runner.executeWithQueryId(session, "SELECT * FROM lineitem JOIN orders " + "ON lineitem.orderkey = orders.orderkey AND orders.totalprice < 0");
    assertEquals(result.getResult().getRowCount(), 0);
    // Probe-side is not scanned at all, due to dynamic filtering:
    // Note that because of the Global Dynamic Filter not being applied in the Memory Connector, we have changed this test
    QueryStats stats = runner.getCoordinator().getQueryManager().getFullQueryInfo(result.getQueryId()).getQueryStats();
    Set rowsRead = stats.getOperatorSummaries().stream().filter(summary -> summary.getOperatorType().equals("ScanFilterAndProjectOperator")).map(summary -> summary.getInputPositions()).collect(toImmutableSet());
    assertEquals(rowsRead, ImmutableSet.of(0L, buildSideRowsCount));
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) ResultWithQueryId(io.prestosql.tests.ResultWithQueryId) Language(org.intellij.lang.annotations.Language) Set(java.util.Set) Test(org.testng.annotations.Test) QueryStats(io.prestosql.execution.QueryStats) MaterializedRow(io.prestosql.testing.MaterializedRow) MaterializedResult(io.prestosql.testing.MaterializedResult) String.format(java.lang.String.format) QualifiedObjectName(io.prestosql.spi.connector.QualifiedObjectName) AbstractTestQueryFramework(io.prestosql.tests.AbstractTestQueryFramework) Assert.assertEquals(io.prestosql.testing.assertions.Assert.assertEquals) List(java.util.List) ENABLE_DYNAMIC_FILTERING(io.prestosql.SystemSessionProperties.ENABLE_DYNAMIC_FILTERING) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) Session(io.prestosql.Session) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) Assert.assertTrue(org.testng.Assert.assertTrue) JOIN_DISTRIBUTION_TYPE(io.prestosql.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE) DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) QueryStats(io.prestosql.execution.QueryStats) MaterializedResult(io.prestosql.testing.MaterializedResult) Session(io.prestosql.Session) Test(org.testng.annotations.Test)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)4 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)4 Session (io.prestosql.Session)4 ENABLE_DYNAMIC_FILTERING (io.prestosql.SystemSessionProperties.ENABLE_DYNAMIC_FILTERING)4 JOIN_DISTRIBUTION_TYPE (io.prestosql.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE)4 QueryStats (io.prestosql.execution.QueryStats)4 QualifiedObjectName (io.prestosql.spi.connector.QualifiedObjectName)4 FeaturesConfig (io.prestosql.sql.analyzer.FeaturesConfig)4 MaterializedResult (io.prestosql.testing.MaterializedResult)4 MaterializedRow (io.prestosql.testing.MaterializedRow)4 Assert.assertEquals (io.prestosql.testing.assertions.Assert.assertEquals)4 AbstractTestQueryFramework (io.prestosql.tests.AbstractTestQueryFramework)4 DistributedQueryRunner (io.prestosql.tests.DistributedQueryRunner)4 ResultWithQueryId (io.prestosql.tests.ResultWithQueryId)4 String.format (java.lang.String.format)4 List (java.util.List)4 Set (java.util.Set)4 Language (org.intellij.lang.annotations.Language)4 Assert.assertTrue (org.testng.Assert.assertTrue)4 Test (org.testng.annotations.Test)4