Search in sources :

Example 1 with SqlEnvironmentConfig

use of com.facebook.presto.sql.SqlEnvironmentConfig 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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SqlParserOptions(com.facebook.presto.sql.parser.SqlParserOptions) AllowAllAccessControl(com.facebook.presto.security.AllowAllAccessControl) QueryId(com.facebook.presto.spi.QueryId) SessionPropertyManager(com.facebook.presto.metadata.SessionPropertyManager) SqlEnvironmentConfig(com.facebook.presto.sql.SqlEnvironmentConfig) Test(org.testng.annotations.Test)

Example 2 with SqlEnvironmentConfig

use of com.facebook.presto.sql.SqlEnvironmentConfig 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));
}
Also used : SqlParserOptions(com.facebook.presto.sql.parser.SqlParserOptions) AllowAllAccessControl(com.facebook.presto.security.AllowAllAccessControl) QueryId(com.facebook.presto.spi.QueryId) SessionPropertyManager(com.facebook.presto.metadata.SessionPropertyManager) SqlEnvironmentConfig(com.facebook.presto.sql.SqlEnvironmentConfig) Session(com.facebook.presto.Session) Test(org.testng.annotations.Test)

Aggregations

SessionPropertyManager (com.facebook.presto.metadata.SessionPropertyManager)2 AllowAllAccessControl (com.facebook.presto.security.AllowAllAccessControl)2 QueryId (com.facebook.presto.spi.QueryId)2 SqlEnvironmentConfig (com.facebook.presto.sql.SqlEnvironmentConfig)2 SqlParserOptions (com.facebook.presto.sql.parser.SqlParserOptions)2 Test (org.testng.annotations.Test)2 Session (com.facebook.presto.Session)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1