use of com.facebook.presto.sql.parser.SqlParserOptions in project presto by prestodb.
the class TestHttpRequestSessionContext method testSessionContext.
@Test
public void testSessionContext() {
HttpServletRequest request = new MockHttpServletRequest(ImmutableListMultimap.<String, String>builder().put(PRESTO_USER, "testUser").put(PRESTO_SOURCE, "testSource").put(PRESTO_CATALOG, "testCatalog").put(PRESTO_SCHEMA, "testSchema").put(PRESTO_LANGUAGE, "zh-TW").put(PRESTO_TIME_ZONE, "Asia/Taipei").put(PRESTO_CLIENT_INFO, "client-info").put(PRESTO_SESSION, QUERY_MAX_MEMORY + "=1GB").put(PRESTO_SESSION, JOIN_DISTRIBUTION_TYPE + "=partitioned," + HASH_PARTITION_COUNT + " = 43").put(PRESTO_PREPARED_STATEMENT, "query1=select * from foo,query2=select * from bar").put(PRESTO_ROLE, "foo_connector=ALL").put(PRESTO_ROLE, "bar_connector=NONE").put(PRESTO_ROLE, "foobar_connector=ROLE{role}").put(PRESTO_EXTRA_CREDENTIAL, "test.token.foo=bar").put(PRESTO_EXTRA_CREDENTIAL, "test.token.abc=xyz").put(PRESTO_SESSION_FUNCTION, format("%s=%s,%s=%s", urlEncode(SERIALIZED_SQL_FUNCTION_ID_ADD), urlEncode(SERIALIZED_SQL_FUNCTION_ADD), urlEncode(SERIALIZED_SQL_FUNCTION_ID_ADD_1_TO_INT_ARRAY), urlEncode(SERIALIZED_SQL_FUNCTION_ADD_1_to_INT_ARRAY))).build(), "testRemote");
HttpRequestSessionContext context = new HttpRequestSessionContext(request, new SqlParserOptions());
assertEquals(context.getSource(), "testSource");
assertEquals(context.getCatalog(), "testCatalog");
assertEquals(context.getSchema(), "testSchema");
assertEquals(context.getIdentity(), new Identity("testUser", Optional.empty()));
assertEquals(context.getClientInfo(), "client-info");
assertEquals(context.getLanguage(), "zh-TW");
assertEquals(context.getTimeZoneId(), "Asia/Taipei");
assertEquals(context.getSystemProperties(), ImmutableMap.of(QUERY_MAX_MEMORY, "1GB", JOIN_DISTRIBUTION_TYPE, "partitioned", HASH_PARTITION_COUNT, "43"));
assertEquals(context.getPreparedStatements(), ImmutableMap.of("query1", "select * from foo", "query2", "select * from bar"));
assertEquals(context.getIdentity().getRoles(), ImmutableMap.of("foo_connector", new SelectedRole(SelectedRole.Type.ALL, Optional.empty()), "bar_connector", new SelectedRole(SelectedRole.Type.NONE, Optional.empty()), "foobar_connector", new SelectedRole(SelectedRole.Type.ROLE, Optional.of("role"))));
assertEquals(context.getIdentity().getExtraCredentials(), ImmutableMap.of("test.token.foo", "bar", "test.token.abc", "xyz"));
assertEquals(context.getSessionFunctions(), ImmutableMap.of(SQL_FUNCTION_ID_ADD, SQL_FUNCTION_ADD, SQL_FUNCTION_ID_ADD1_TO_INT_ARRAY, SQL_FUNCTION_ADD_1_TO_INT_ARRAY));
}
use of com.facebook.presto.sql.parser.SqlParserOptions in project presto by prestodb.
the class TestHttpRequestSessionContext method testExtraCredentials.
@Test
public void testExtraCredentials() {
HttpServletRequest request = new MockHttpServletRequest(ImmutableListMultimap.<String, String>builder().put(PRESTO_USER, "testUser").put(PRESTO_SOURCE, "testSource").put(PRESTO_CATALOG, "testCatalog").put(PRESTO_SCHEMA, "testSchema").put(PRESTO_LANGUAGE, "zh-TW").put(PRESTO_TIME_ZONE, "Asia/Taipei").put(PRESTO_CLIENT_INFO, "client-info").put(PRESTO_SESSION, QUERY_MAX_MEMORY + "=1GB").put(PRESTO_SESSION, JOIN_DISTRIBUTION_TYPE + "=partitioned," + HASH_PARTITION_COUNT + " = 43").put(PRESTO_PREPARED_STATEMENT, "query1=select * from foo,query2=select * from bar").put(PRESTO_ROLE, "foo_connector=ALL").put(PRESTO_ROLE, "bar_connector=NONE").put(PRESTO_ROLE, "foobar_connector=ROLE{role}").put(PRESTO_EXTRA_CREDENTIAL, "test.token.key1=" + urlEncode("bar=ab===,d")).put(PRESTO_EXTRA_CREDENTIAL, "test.token.key2=bar=ab===").put(PRESTO_EXTRA_CREDENTIAL, "test.json=" + urlEncode("{\"a\" : \"b\", \"c\" : \"d=\"}") + ", test.token.key3 = abc=cd").put(PRESTO_EXTRA_CREDENTIAL, "test.token.abc=xyz").build(), "testRemote");
HttpRequestSessionContext context = new HttpRequestSessionContext(request, new SqlParserOptions());
assertEquals(context.getIdentity().getExtraCredentials(), ImmutableMap.builder().put("test.token.key1", "bar=ab===,d").put("test.token.key2", "bar=ab===").put("test.token.key3", "abc=cd").put("test.json", "{\"a\" : \"b\", \"c\" : \"d=\"}").put("test.token.abc", "xyz").build());
}
use of com.facebook.presto.sql.parser.SqlParserOptions in project presto by prestodb.
the class TestQuerySessionSupplier method testInvalidTimeZone.
@Test(expectedExceptions = TimeZoneNotSupportedException.class)
public void testInvalidTimeZone() {
HttpServletRequest request = new MockHttpServletRequest(ImmutableListMultimap.<String, String>builder().put(PRESTO_USER, "testUser").put(PRESTO_TIME_ZONE, "unknown_timezone").build(), "testRemote");
HttpRequestSessionContext context = new HttpRequestSessionContext(request, new SqlParserOptions());
QuerySessionSupplier sessionSupplier = new QuerySessionSupplier(createTestTransactionManager(), new AllowAllAccessControl(), new SessionPropertyManager(), new SqlEnvironmentConfig());
sessionSupplier.createSession(new QueryId("test_query_id"), context);
}
use of com.facebook.presto.sql.parser.SqlParserOptions in project presto by prestodb.
the class TestJdbcWarnings method setupServer.
@BeforeClass
public void setupServer() throws Exception {
server = new TestingPrestoServer(true, ImmutableMap.<String, String>builder().put("testing-warning-collector.add-warnings", "true").put("testing-warning-collector.preloaded-warnings", String.valueOf(PRELOADED_WARNINGS)).build(), null, null, new SqlParserOptions(), ImmutableList.of());
server.installPlugin(new TpchPlugin());
server.createCatalog("tpch", "tpch");
server.installPlugin(new BlackHolePlugin());
server.createCatalog("blackhole", "blackhole");
waitForNodeRefresh(server);
}
use of com.facebook.presto.sql.parser.SqlParserOptions in project presto by prestodb.
the class TpchQueryRunner method createQueryRunner.
public static DistributedQueryRunner createQueryRunner(Map<String, String> extraProperties, Map<String, String> coordinatorProperties) throws Exception {
Session session = testSessionBuilder().setSource("test").setCatalog("tpch").setSchema("tiny").build();
DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, 4, extraProperties, coordinatorProperties, new SqlParserOptions());
try {
queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog("tpch", "tpch");
return queryRunner;
} catch (Exception e) {
queryRunner.close();
throw e;
}
}
Aggregations