Search in sources :

Example 1 with SessionPropertyManager

use of com.facebook.presto.metadata.SessionPropertyManager in project presto by prestodb.

the class TestHttpRequestSessionFactory method testInvalidTimeZone.

@Test(expectedExceptions = PrestoException.class)
public void testInvalidTimeZone() throws Exception {
    HttpServletRequest request = new MockHttpServletRequest(ImmutableListMultimap.<String, String>builder().put(PRESTO_USER, "testUser").put(PRESTO_TIME_ZONE, "unknown_timezone").build(), "testRemote");
    HttpRequestSessionFactory sessionFactory = new HttpRequestSessionFactory(request);
    sessionFactory.createSession(new QueryId("test_query_id"), createTestTransactionManager(), new AllowAllAccessControl(), new SessionPropertyManager());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) AllowAllAccessControl(com.facebook.presto.security.AllowAllAccessControl) QueryId(com.facebook.presto.spi.QueryId) SessionPropertyManager(com.facebook.presto.metadata.SessionPropertyManager) Test(org.testng.annotations.Test)

Example 2 with SessionPropertyManager

use of com.facebook.presto.metadata.SessionPropertyManager in project presto by prestodb.

the class TestHttpRequestSessionFactory method testCreateSession.

@Test
public void testCreateSession() throws Exception {
    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, DISTRIBUTED_JOIN + "=true," + HASH_PARTITION_COUNT + " = 43").put(PRESTO_PREPARED_STATEMENT, "query1=select * from foo,query2=select * from bar").build(), "testRemote");
    HttpRequestSessionFactory sessionFactory = new HttpRequestSessionFactory(request);
    Session session = sessionFactory.createSession(new QueryId("test_query_id"), createTestTransactionManager(), new AllowAllAccessControl(), new SessionPropertyManager());
    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.getSystemProperties(), ImmutableMap.<String, String>builder().put(QUERY_MAX_MEMORY, "1GB").put(DISTRIBUTED_JOIN, "true").put(HASH_PARTITION_COUNT, "43").build());
    assertEquals(session.getPreparedStatements(), ImmutableMap.<String, String>builder().put("query1", "select * from foo").put("query2", "select * from bar").build());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) AllowAllAccessControl(com.facebook.presto.security.AllowAllAccessControl) QueryId(com.facebook.presto.spi.QueryId) SessionPropertyManager(com.facebook.presto.metadata.SessionPropertyManager) Session(com.facebook.presto.Session) Test(org.testng.annotations.Test)

Example 3 with SessionPropertyManager

use of com.facebook.presto.metadata.SessionPropertyManager in project presto by prestodb.

the class TestLocalBinarySpilledQueries method createLocalQueryRunner.

private static LocalQueryRunner createLocalQueryRunner() {
    Session defaultSession = testSessionBuilder().setCatalog("local").setSchema(TINY_SCHEMA_NAME).setSystemProperty(SystemSessionProperties.SPILL_ENABLED, "true").setSystemProperty(SystemSessionProperties.OPERATOR_MEMORY_LIMIT_BEFORE_SPILL, //spill constantly
    "1B").build();
    LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);
    // add the tpch catalog
    // local queries run directly against the generator
    localQueryRunner.createCatalog(defaultSession.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
    localQueryRunner.getMetadata().addFunctions(CUSTOM_FUNCTIONS);
    SessionPropertyManager sessionPropertyManager = localQueryRunner.getMetadata().getSessionPropertyManager();
    sessionPropertyManager.addSystemSessionProperties(TEST_SYSTEM_PROPERTIES);
    sessionPropertyManager.addConnectorSessionProperties(new ConnectorId(TESTING_CATALOG), TEST_CATALOG_PROPERTIES);
    return localQueryRunner;
}
Also used : TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) SessionPropertyManager(com.facebook.presto.metadata.SessionPropertyManager) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) Session(com.facebook.presto.Session) ConnectorId(com.facebook.presto.connector.ConnectorId)

Example 4 with SessionPropertyManager

use of com.facebook.presto.metadata.SessionPropertyManager in project presto by prestodb.

the class RaptorQueryRunner method createSession.

public static Session createSession(String schema) {
    SessionPropertyManager sessionPropertyManager = new SessionPropertyManager();
    sessionPropertyManager.addConnectorSessionProperties(new ConnectorId("raptor"), new RaptorSessionProperties(new StorageManagerConfig()).getSessionProperties());
    return testSessionBuilder(sessionPropertyManager).setCatalog("raptor").setSchema(schema).setSystemProperty("enable_intermediate_aggregations", "true").build();
}
Also used : SessionPropertyManager(com.facebook.presto.metadata.SessionPropertyManager) ConnectorId(com.facebook.presto.spi.ConnectorId) StorageManagerConfig(com.facebook.presto.raptor.storage.StorageManagerConfig)

Example 5 with SessionPropertyManager

use of com.facebook.presto.metadata.SessionPropertyManager in project presto by prestodb.

the class TestLocalQueries method createLocalQueryRunner.

public static LocalQueryRunner createLocalQueryRunner() {
    Session defaultSession = testSessionBuilder().setCatalog("local").setSchema(TINY_SCHEMA_NAME).setSystemProperty(PUSH_PARTIAL_AGGREGATION_THROUGH_JOIN, "true").build();
    LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);
    // add the tpch catalog
    // local queries run directly against the generator
    localQueryRunner.createCatalog(defaultSession.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
    localQueryRunner.getMetadata().registerBuiltInFunctions(CUSTOM_FUNCTIONS);
    SessionPropertyManager sessionPropertyManager = localQueryRunner.getMetadata().getSessionPropertyManager();
    sessionPropertyManager.addSystemSessionProperties(TEST_SYSTEM_PROPERTIES);
    sessionPropertyManager.addConnectorSessionProperties(new ConnectorId(TESTING_CATALOG), TEST_CATALOG_PROPERTIES);
    return localQueryRunner;
}
Also used : TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) SessionPropertyManager(com.facebook.presto.metadata.SessionPropertyManager) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) Session(com.facebook.presto.Session) ConnectorId(com.facebook.presto.spi.ConnectorId)

Aggregations

SessionPropertyManager (com.facebook.presto.metadata.SessionPropertyManager)26 Test (org.testng.annotations.Test)15 Session (com.facebook.presto.Session)11 ConnectorId (com.facebook.presto.spi.ConnectorId)9 InMemoryNodeManager (com.facebook.presto.metadata.InMemoryNodeManager)8 InternalNode (com.facebook.presto.metadata.InternalNode)8 QueryId (com.facebook.presto.spi.QueryId)8 AllowAllAccessControl (com.facebook.presto.security.AllowAllAccessControl)4 LocalQueryRunner (com.facebook.presto.testing.LocalQueryRunner)4 TpchConnectorFactory (com.facebook.presto.tpch.TpchConnectorFactory)4 NodeMemoryConfig (com.facebook.presto.memory.NodeMemoryConfig)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 SystemSessionProperties (com.facebook.presto.SystemSessionProperties)2 ConnectorId (com.facebook.presto.connector.ConnectorId)2 QueryManagerConfig (com.facebook.presto.execution.QueryManagerConfig)2 TaskManagerConfig (com.facebook.presto.execution.TaskManagerConfig)2 NodeSchedulerConfig (com.facebook.presto.execution.scheduler.NodeSchedulerConfig)2 WarningCollectorConfig (com.facebook.presto.execution.warnings.WarningCollectorConfig)2 MemoryManagerConfig (com.facebook.presto.memory.MemoryManagerConfig)2 PrestoException (com.facebook.presto.spi.PrestoException)2