Search in sources :

Example 6 with Session

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

the class AbstractTestEngineOnlyQueries method testTimeLiterals.

@Test
public void testTimeLiterals() {
    Session chicago = Session.builder(getSession()).setTimeZoneKey(TimeZoneKey.getTimeZoneKey("America/Chicago")).build();
    Session kathmandu = Session.builder(getSession()).setTimeZoneKey(TimeZoneKey.getTimeZoneKey("Asia/Kathmandu")).build();
    assertEquals(computeScalar("SELECT DATE '2013-03-22'"), LocalDate.of(2013, 3, 22));
    assertQuery("SELECT DATE '2013-03-22'");
    assertQuery(chicago, "SELECT DATE '2013-03-22'");
    assertQuery(kathmandu, "SELECT DATE '2013-03-22'");
    assertEquals(computeScalar("SELECT TIME '3:04:05'"), LocalTime.of(3, 4, 5, 0));
    assertEquals(computeScalar("SELECT TIME '3:04:05.123'"), LocalTime.of(3, 4, 5, 123_000_000));
    assertQuery("SELECT TIME '3:04:05'");
    assertQuery("SELECT TIME '0:04:05'");
    // TODO to assert Query: chicago, "SELECT TIME '3:04:05'";
    // TODO to assert Query: kathmandu, "SELECT TIME '3:04:05'";
    assertEquals(computeScalar("SELECT TIME '01:02:03.400 Z'"), OffsetTime.of(1, 2, 3, 400_000_000, ZoneOffset.UTC));
    assertEquals(computeScalar("SELECT TIME '01:02:03.400 UTC'"), OffsetTime.of(1, 2, 3, 400_000_000, ZoneOffset.UTC));
    assertEquals(computeScalar("SELECT TIME '3:04:05 +06:00'"), OffsetTime.of(3, 4, 5, 0, ZoneOffset.ofHoursMinutes(6, 0)));
    assertEquals(computeScalar("SELECT TIME '3:04:05 +0507'"), OffsetTime.of(3, 4, 5, 0, ZoneOffset.ofHoursMinutes(5, 7)));
    assertEquals(computeScalar("SELECT TIME '3:04:05 +03'"), OffsetTime.of(3, 4, 5, 0, ZoneOffset.ofHoursMinutes(3, 0)));
    assertEquals(computeScalar("SELECT TIMESTAMP '1960-01-22 3:04:05'"), LocalDateTime.of(1960, 1, 22, 3, 4, 5));
    assertEquals(computeScalar("SELECT TIMESTAMP '1960-01-22 3:04:05.123'"), LocalDateTime.of(1960, 1, 22, 3, 4, 5, 123_000_000));
    assertQuery("SELECT TIMESTAMP '1960-01-22 3:04:05'");
    assertQuery("SELECT TIMESTAMP '1960-01-22 3:04:05.123'");
    // TODO to assert Query: chicago, "SELECT TIMESTAMP '1960-01-22 3:04:05.123'";
    // TODO to assert Query: kathmandu, "SELECT TIMESTAMP '1960-01-22 3:04:05.123'";
    assertEquals(computeScalar("SELECT TIMESTAMP '1960-01-22 3:04:05 +06:00'"), ZonedDateTime.of(1960, 1, 22, 3, 4, 5, 0, ZoneOffset.ofHoursMinutes(6, 0)));
}
Also used : Session(io.prestosql.Session) Test(org.testng.annotations.Test)

Example 7 with Session

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

the class TestQueryPlanDeterminism method createLocalQueryRunner.

private static LocalQueryRunner createLocalQueryRunner() {
    Session defaultSession = testSessionBuilder().setCatalog("local").setSchema(TINY_SCHEMA_NAME).build();
    LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);
    // add the tpch catalog
    // local queries run directly against the generator
    localQueryRunner.createCatalog(defaultSession.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
    localQueryRunner.getMetadata().getFunctionAndTypeManager().registerBuiltInFunctions(CUSTOM_FUNCTIONS);
    SessionPropertyManager sessionPropertyManager = localQueryRunner.getMetadata().getSessionPropertyManager();
    sessionPropertyManager.addSystemSessionProperties(TEST_SYSTEM_PROPERTIES);
    sessionPropertyManager.addConnectorSessionProperties(new CatalogName(TESTING_CATALOG), TEST_CATALOG_PROPERTIES);
    return localQueryRunner;
}
Also used : TpchConnectorFactory(io.prestosql.plugin.tpch.TpchConnectorFactory) SessionPropertyManager(io.prestosql.metadata.SessionPropertyManager) CatalogName(io.prestosql.spi.connector.CatalogName) LocalQueryRunner(io.prestosql.testing.LocalQueryRunner) Session(io.prestosql.Session)

Example 8 with Session

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

the class TestTpchLocalStats method setUp.

@BeforeClass
public void setUp() {
    Session defaultSession = testSessionBuilder().setCatalog("tpch").setSchema(TINY_SCHEMA_NAME).setSystemProperty(PREFER_PARTIAL_AGGREGATION, "false").build();
    LocalQueryRunner queryRunner = new LocalQueryRunner(defaultSession);
    queryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of(TPCH_COLUMN_NAMING_PROPERTY, ColumnNaming.STANDARD.name()));
    statisticsAssertion = new StatisticsAssertion(queryRunner);
}
Also used : TpchConnectorFactory(io.prestosql.plugin.tpch.TpchConnectorFactory) StatisticsAssertion(io.prestosql.tests.statistics.StatisticsAssertion) LocalQueryRunner(io.prestosql.testing.LocalQueryRunner) Session(io.prestosql.Session) BeforeClass(org.testng.annotations.BeforeClass)

Example 9 with Session

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

the class TestDistributedQueriesIndexed method createQueryRunner.

private static DistributedQueryRunner createQueryRunner() throws Exception {
    Session session = testSessionBuilder().setCatalog("tpch_indexed").setSchema(TINY_SCHEMA_NAME).build();
    DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, 3);
    queryRunner.installPlugin(new IndexedTpchPlugin(INDEX_SPEC));
    queryRunner.createCatalog("tpch_indexed", "tpch_indexed");
    return queryRunner;
}
Also used : IndexedTpchPlugin(io.prestosql.tests.tpch.IndexedTpchPlugin) Session(io.prestosql.Session)

Example 10 with Session

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

the class TestDistributedSpilledQueries method createQueryRunner.

public static DistributedQueryRunner createQueryRunner() throws Exception {
    Session defaultSession = testSessionBuilder().setCatalog("tpch").setSchema(TINY_SCHEMA_NAME).setSystemProperty(SystemSessionProperties.TASK_CONCURRENCY, "2").setSystemProperty(SystemSessionProperties.SPILL_ENABLED, "true").setSystemProperty(SystemSessionProperties.SPILL_ORDER_BY, "true").setSystemProperty(SystemSessionProperties.AGGREGATION_OPERATOR_UNSPILL_MEMORY_LIMIT, "128kB").build();
    Map<String, String> extraProperties = new HashMap<String, String>();
    extraProperties.put("experimental.spiller-spill-path", Paths.get(System.getProperty("java.io.tmpdir"), "presto", "spills").toString());
    extraProperties.put("experimental.spiller-max-used-space-threshold", "1.0");
    // revoke always
    extraProperties.put("experimental.memory-revoking-threshold", "0.0");
    extraProperties.put("experimental.memory-revoking-target", "0.0");
    extraProperties.put("experimental.spiller-spill-to-hdfs", "false");
    DistributedQueryRunner queryRunner = new DistributedQueryRunner(defaultSession, 2, extraProperties);
    try {
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.installPlugin(new HetuFileSystemClientPlugin());
        queryRunner.createCatalog("tpch", "tpch");
        return queryRunner;
    } catch (Exception e) {
        queryRunner.close();
        throw e;
    }
}
Also used : HetuFileSystemClientPlugin(io.hetu.core.filesystem.HetuFileSystemClientPlugin) HashMap(java.util.HashMap) TpchPlugin(io.prestosql.plugin.tpch.TpchPlugin) Session(io.prestosql.Session)

Aggregations

Session (io.prestosql.Session)281 Test (org.testng.annotations.Test)147 ConnectorSession (io.prestosql.spi.connector.ConnectorSession)54 List (java.util.List)53 Optional (java.util.Optional)51 MaterializedResult (io.prestosql.testing.MaterializedResult)47 Metadata (io.prestosql.metadata.Metadata)44 QualifiedObjectName (io.prestosql.spi.connector.QualifiedObjectName)44 Map (java.util.Map)44 Objects.requireNonNull (java.util.Objects.requireNonNull)40 TableHandle (io.prestosql.spi.metadata.TableHandle)34 PrestoException (io.prestosql.spi.PrestoException)32 ImmutableList (com.google.common.collect.ImmutableList)31 Type (io.prestosql.spi.type.Type)31 Set (java.util.Set)31 ImmutableMap (com.google.common.collect.ImmutableMap)30 HashMap (java.util.HashMap)30 HeuristicIndexerManager (io.prestosql.heuristicindex.HeuristicIndexerManager)28 AbstractTestIntegrationSmokeTest (io.prestosql.tests.AbstractTestIntegrationSmokeTest)28 ImmutableSet (com.google.common.collect.ImmutableSet)27