use of com.facebook.presto.sql.parser.SqlParserOptions in project presto by prestodb.
the class TestQuerySessionSupplier method testCreateSession.
@Test
public void testCreateSession() {
HttpRequestSessionContext context = new HttpRequestSessionContext(TEST_REQUEST, new SqlParserOptions());
QuerySessionSupplier sessionSupplier = new QuerySessionSupplier(createTestTransactionManager(), new AllowAllAccessControl(), new SessionPropertyManager(), new SqlEnvironmentConfig());
Session session = sessionSupplier.createSession(new QueryId("test_query_id"), context);
assertEquals(session.getQueryId(), new QueryId("test_query_id"));
assertEquals(session.getUser(), "testUser");
assertEquals(session.getSource().get(), "testSource");
assertEquals(session.getCatalog().get(), "testCatalog");
assertEquals(session.getSchema().get(), "testSchema");
assertEquals(session.getLocale(), Locale.TAIWAN);
assertEquals(session.getTimeZoneKey(), getTimeZoneKey("Asia/Taipei"));
assertEquals(session.getRemoteUserAddress().get(), "testRemote");
assertEquals(session.getClientInfo().get(), "client-info");
assertEquals(session.getClientTags(), ImmutableSet.of("tag1", "tag2", "tag3"));
assertEquals(session.getSystemProperties(), ImmutableMap.<String, String>builder().put(QUERY_MAX_MEMORY, "1GB").put(JOIN_DISTRIBUTION_TYPE, "partitioned").put(HASH_PARTITION_COUNT, "43").build());
assertEquals(session.getPreparedStatements(), ImmutableMap.<String, String>builder().put("query1", "select * from foo").put("query2", "select * from bar").build());
assertEquals(session.getSessionFunctions(), ImmutableMap.of(SQL_FUNCTION_ID_ADD, SQL_FUNCTION_ADD));
}
use of com.facebook.presto.sql.parser.SqlParserOptions in project presto by prestodb.
the class TestQuerySessionSupplier method testEmptyClientTags.
@Test
public void testEmptyClientTags() {
HttpServletRequest request1 = new MockHttpServletRequest(ImmutableListMultimap.<String, String>builder().put(PRESTO_USER, "testUser").build(), "remoteAddress");
HttpRequestSessionContext context1 = new HttpRequestSessionContext(request1, new SqlParserOptions());
assertEquals(context1.getClientTags(), ImmutableSet.of());
HttpServletRequest request2 = new MockHttpServletRequest(ImmutableListMultimap.<String, String>builder().put(PRESTO_USER, "testUser").put(PRESTO_CLIENT_TAGS, "").build(), "remoteAddress");
HttpRequestSessionContext context2 = new HttpRequestSessionContext(request2, new SqlParserOptions());
assertEquals(context2.getClientTags(), ImmutableSet.of());
}
use of com.facebook.presto.sql.parser.SqlParserOptions in project presto by prestodb.
the class TestPrestoQuerySourceQuerySupplier method setup.
@BeforeClass
public void setup() throws Exception {
queryRunner = setupPresto();
String host = queryRunner.getServer().getAddress().getHost();
int port = queryRunner.getServer().getAddress().getPort();
Bootstrap app = new Bootstrap(ImmutableList.<Module>builder().add(new SourceQueryModule(ImmutableSet.of())).add(new QueryActionsModule(PrestoExceptionClassifier.defaultBuilder().build(), ImmutableSet.of())).add(binder -> {
configBinder(binder).bindConfig(VerifierConfig.class);
binder.bind(SqlParserOptions.class).toInstance(new SqlParserOptions());
binder.bind(SqlParser.class).in(SINGLETON);
}).build());
injector = app.setRequiredConfigurationProperties(ImmutableMap.<String, String>builder().put("test-id", "10000").put("control.hosts", format("%s,%s", host, host)).put("control.jdbc-port", String.valueOf(port)).put("source-query.supplier", "presto-query").put("source-query.query", SOURCE_FETCHING_QUERY).put("source-query.catalog", CATALOG).put("source-query.schema", SCHEMA).put("source-query.username", "test_user").build()).initialize();
}
Aggregations