Search in sources :

Example 16 with SqlParserOptions

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

Example 17 with SqlParserOptions

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());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SqlParserOptions(com.facebook.presto.sql.parser.SqlParserOptions) Test(org.testng.annotations.Test)

Example 18 with SqlParserOptions

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();
}
Also used : SqlParserOptions(com.facebook.presto.sql.parser.SqlParserOptions) QueryActionsModule(com.facebook.presto.verifier.prestoaction.QueryActionsModule) SqlParser(com.facebook.presto.sql.parser.SqlParser) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

SqlParserOptions (com.facebook.presto.sql.parser.SqlParserOptions)18 Test (org.testng.annotations.Test)7 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 SqlParser (com.facebook.presto.sql.parser.SqlParser)5 CatalogManager (com.facebook.presto.metadata.CatalogManager)4 SessionPropertyManager (com.facebook.presto.metadata.SessionPropertyManager)4 SqlEnvironmentConfig (com.facebook.presto.sql.SqlEnvironmentConfig)4 TpchPlugin (com.facebook.presto.tpch.TpchPlugin)4 JsonBinder.jsonBinder (com.facebook.airlift.json.JsonBinder.jsonBinder)3 BlockEncodingManager (com.facebook.presto.common.block.BlockEncodingManager)3 NodeSchedulerConfig (com.facebook.presto.execution.scheduler.NodeSchedulerConfig)3 FunctionAndTypeManager (com.facebook.presto.metadata.FunctionAndTypeManager)3 HandleJsonModule (com.facebook.presto.metadata.HandleJsonModule)3 StaticCatalogStore (com.facebook.presto.metadata.StaticCatalogStore)3 StaticFunctionNamespaceStore (com.facebook.presto.metadata.StaticFunctionNamespaceStore)3 FeaturesConfig (com.facebook.presto.sql.analyzer.FeaturesConfig)3 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)3 Objects.requireNonNull (java.util.Objects.requireNonNull)3 Threads.daemonThreadsNamed (com.facebook.airlift.concurrent.Threads.daemonThreadsNamed)2 AbstractConfigurationAwareModule (com.facebook.airlift.configuration.AbstractConfigurationAwareModule)2