use of com.facebook.presto.Session in project presto by prestodb.
the class TestBlackHoleSmoke method dataGenerationUsage.
@Test
public void dataGenerationUsage() {
Session session = testSessionBuilder().setCatalog("blackhole").setSchema("default").build();
assertThatQueryReturnsValue(format("CREATE TABLE nation WITH ( %s = 3, %s = 2, %s = 1 ) as SELECT * FROM tpch.tiny.nation", ROWS_PER_PAGE_PROPERTY, PAGES_PER_SPLIT_PROPERTY, SPLIT_COUNT_PROPERTY), 25L, session);
assertThatQueryReturnsValue("SELECT count(*) FROM nation", 6L, session);
assertThatQueryReturnsValue("INSERT INTO nation SELECT * FROM tpch.tiny.nation", 25L, session);
assertThatQueryReturnsValue("SELECT count(*) FROM nation", 6L, session);
MaterializedResult rows = queryRunner.execute(session, "SELECT * FROM nation LIMIT 1");
assertEquals(rows.getRowCount(), 1);
MaterializedRow row = Iterables.getOnlyElement(rows);
assertEquals(row.getFieldCount(), 4);
assertEquals(row.getField(0), 0L);
assertEquals(row.getField(1), "****************");
assertEquals(row.getField(2), 0L);
assertEquals(row.getField(3), "****************");
assertThatQueryReturnsValue("DROP TABLE nation", true);
}
use of com.facebook.presto.Session in project presto by prestodb.
the class TestBlackHoleSmoke method pageProcessingDelay.
@Test
public void pageProcessingDelay() throws Exception {
Session session = testSessionBuilder().setCatalog("blackhole").setSchema("default").build();
Duration pageProcessingDelay = new Duration(1, SECONDS);
assertThatQueryReturnsValue(format("CREATE TABLE nation WITH ( %s = 8, %s = 1, %s = 1, %s = 1, %s = '%s' ) AS " + "SELECT * FROM tpch.tiny.nation", FIELD_LENGTH_PROPERTY, ROWS_PER_PAGE_PROPERTY, PAGES_PER_SPLIT_PROPERTY, SPLIT_COUNT_PROPERTY, PAGE_PROCESSING_DELAY, pageProcessingDelay), 25L, session);
Stopwatch stopwatch = Stopwatch.createStarted();
assertEquals(queryRunner.execute(session, "SELECT * FROM nation").getRowCount(), 1);
queryRunner.execute(session, "INSERT INTO nation SELECT CAST(null AS BIGINT), CAST(null AS VARCHAR(25)), CAST(null AS BIGINT), CAST(null AS VARCHAR(152))");
stopwatch.stop();
assertGreaterThan(stopwatch.elapsed(MILLISECONDS), pageProcessingDelay.toMillis());
assertThatQueryReturnsValue("DROP TABLE nation", true);
}
use of com.facebook.presto.Session in project presto by prestodb.
the class TestDateTimeFunctions method testLocale.
@Test
public void testLocale() {
Locale locale = Locale.JAPANESE;
Session localeSession = testSessionBuilder().setTimeZoneKey(TIME_ZONE_KEY).setLocale(locale).build();
FunctionAssertions localeAssertions = new FunctionAssertions(localeSession);
String dateTimeLiteral = "TIMESTAMP '2001-01-09 13:04:05.321'";
localeAssertions.assertFunction("date_format(" + dateTimeLiteral + ", '%a')", VARCHAR, "火");
localeAssertions.assertFunction("date_format(" + dateTimeLiteral + ", '%W')", VARCHAR, "火曜日");
localeAssertions.assertFunction("date_format(" + dateTimeLiteral + ", '%p')", VARCHAR, "午後");
localeAssertions.assertFunction("date_format(" + dateTimeLiteral + ", '%r')", VARCHAR, "01:04:05 午後");
localeAssertions.assertFunction("date_format(" + dateTimeLiteral + ", '%b')", VARCHAR, "1");
localeAssertions.assertFunction("date_format(" + dateTimeLiteral + ", '%M')", VARCHAR, "1月");
localeAssertions.assertFunction("format_datetime(" + dateTimeLiteral + ", 'EEE')", VARCHAR, "火");
localeAssertions.assertFunction("format_datetime(" + dateTimeLiteral + ", 'EEEE')", VARCHAR, "火曜日");
localeAssertions.assertFunction("format_datetime(" + dateTimeLiteral + ", 'a')", VARCHAR, "午後");
localeAssertions.assertFunction("format_datetime(" + dateTimeLiteral + ", 'MMM')", VARCHAR, "1");
localeAssertions.assertFunction("format_datetime(" + dateTimeLiteral + ", 'MMMM')", VARCHAR, "1月");
localeAssertions.assertFunction("date_parse('2013-05-17 12:35:10 午後', '%Y-%m-%d %h:%i:%s %p')", TimestampType.TIMESTAMP, toTimestamp(new DateTime(2013, 5, 17, 12, 35, 10, 0, DATE_TIME_ZONE), localeSession));
localeAssertions.assertFunction("date_parse('2013-05-17 12:35:10 午前', '%Y-%m-%d %h:%i:%s %p')", TimestampType.TIMESTAMP, toTimestamp(new DateTime(2013, 5, 17, 0, 35, 10, 0, DATE_TIME_ZONE), localeSession));
localeAssertions.assertFunction("parse_datetime('2013-05-17 12:35:10 午後', 'yyyy-MM-dd hh:mm:ss a')", TIMESTAMP_WITH_TIME_ZONE, toTimestampWithTimeZone(new DateTime(2013, 5, 17, 12, 35, 10, 0, DATE_TIME_ZONE)));
localeAssertions.assertFunction("parse_datetime('2013-05-17 12:35:10 午前', 'yyyy-MM-dd hh:mm:ss aaa')", TIMESTAMP_WITH_TIME_ZONE, toTimestampWithTimeZone(new DateTime(2013, 5, 17, 0, 35, 10, 0, DATE_TIME_ZONE)));
}
use of com.facebook.presto.Session in project presto by prestodb.
the class TestMySqlIntegrationSmokeTest method testNameEscaping.
@Test
public void testNameEscaping() throws Exception {
Session session = testSessionBuilder().setCatalog("mysql").setSchema("test_database").build();
assertFalse(getQueryRunner().tableExists(session, "test_table"));
assertUpdate(session, "CREATE TABLE test_table AS SELECT 123 x", 1);
assertTrue(getQueryRunner().tableExists(session, "test_table"));
assertQuery(session, "SELECT * FROM test_table", "SELECT 123");
assertUpdate(session, "DROP TABLE test_table");
assertFalse(getQueryRunner().tableExists(session, "test_table"));
}
use of com.facebook.presto.Session in project presto by prestodb.
the class MemoryQueryRunner method createQueryRunner.
public static DistributedQueryRunner createQueryRunner(Map<String, String> extraProperties) throws Exception {
Session session = testSessionBuilder().setCatalog("memory").setSchema("default").build();
DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, 4, extraProperties);
try {
queryRunner.installPlugin(new MemoryPlugin());
queryRunner.createCatalog("memory", "memory", ImmutableMap.of());
queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog("tpch", "tpch", ImmutableMap.of());
copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, session, TpchTable.getTables());
return queryRunner;
} catch (Exception e) {
closeAllSuppress(e, queryRunner);
throw e;
}
}
Aggregations