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)));
}
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;
}
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);
}
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;
}
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;
}
}
Aggregations