Search in sources :

Example 1 with TestingSessionPropertyConfigurationManagerFactory

use of com.facebook.presto.spi.session.TestingSessionPropertyConfigurationManagerFactory in project presto by prestodb.

the class TestSessionPropertyDefaults method testApplyDefaultProperties.

@Test
public void testApplyDefaultProperties() {
    SessionPropertyDefaults sessionPropertyDefaults = new SessionPropertyDefaults(TEST_NODE_INFO);
    SessionPropertyConfigurationManagerFactory factory = new TestingSessionPropertyConfigurationManagerFactory(new SystemSessionPropertyConfiguration(ImmutableMap.<String, String>builder().put(QUERY_MAX_MEMORY, "override").put("system_default", "system_default").build(), ImmutableMap.of("override", "overridden")), ImmutableMap.of("testCatalog", ImmutableMap.<String, String>builder().put("explicit_set", "override").put("catalog_default", "catalog_default").build()));
    sessionPropertyDefaults.addConfigurationManagerFactory(factory);
    sessionPropertyDefaults.setConfigurationManager(factory.getName(), ImmutableMap.of());
    Session session = Session.builder(new SessionPropertyManager()).setQueryId(new QueryId("test_query_id")).setIdentity(new Identity("testUser", Optional.empty())).setSystemProperty(QUERY_MAX_MEMORY, "1GB").setSystemProperty(JOIN_DISTRIBUTION_TYPE, "partitioned").setSystemProperty(HASH_PARTITION_COUNT, "43").setSystemProperty("override", "should be overridden").setCatalogSessionProperty("testCatalog", "explicit_set", "explicit_set").build();
    assertEquals(session.getSystemProperties(), ImmutableMap.<String, String>builder().put(QUERY_MAX_MEMORY, "1GB").put(JOIN_DISTRIBUTION_TYPE, "partitioned").put(HASH_PARTITION_COUNT, "43").put("override", "should be overridden").build());
    assertEquals(session.getUnprocessedCatalogProperties(), ImmutableMap.of("testCatalog", ImmutableMap.<String, String>builder().put("explicit_set", "explicit_set").build()));
    session = sessionPropertyDefaults.newSessionWithDefaultProperties(session, Optional.empty(), Optional.of(TEST_RESOURCE_GROUP_ID));
    assertEquals(session.getSystemProperties(), ImmutableMap.<String, String>builder().put(QUERY_MAX_MEMORY, "1GB").put(JOIN_DISTRIBUTION_TYPE, "partitioned").put(HASH_PARTITION_COUNT, "43").put("system_default", "system_default").put("override", "overridden").build());
    assertEquals(session.getUnprocessedCatalogProperties(), ImmutableMap.of("testCatalog", ImmutableMap.<String, String>builder().put("explicit_set", "explicit_set").put("catalog_default", "catalog_default").build()));
}
Also used : SystemSessionPropertyConfiguration(com.facebook.presto.spi.session.SessionPropertyConfigurationManager.SystemSessionPropertyConfiguration) QueryId(com.facebook.presto.spi.QueryId) TestingSessionPropertyConfigurationManagerFactory(com.facebook.presto.spi.session.TestingSessionPropertyConfigurationManagerFactory) SessionPropertyManager(com.facebook.presto.metadata.SessionPropertyManager) SessionPropertyConfigurationManagerFactory(com.facebook.presto.spi.session.SessionPropertyConfigurationManagerFactory) TestingSessionPropertyConfigurationManagerFactory(com.facebook.presto.spi.session.TestingSessionPropertyConfigurationManagerFactory) Identity(com.facebook.presto.spi.security.Identity) Session(com.facebook.presto.Session) Test(org.testng.annotations.Test)

Aggregations

Session (com.facebook.presto.Session)1 SessionPropertyManager (com.facebook.presto.metadata.SessionPropertyManager)1 QueryId (com.facebook.presto.spi.QueryId)1 Identity (com.facebook.presto.spi.security.Identity)1 SystemSessionPropertyConfiguration (com.facebook.presto.spi.session.SessionPropertyConfigurationManager.SystemSessionPropertyConfiguration)1 SessionPropertyConfigurationManagerFactory (com.facebook.presto.spi.session.SessionPropertyConfigurationManagerFactory)1 TestingSessionPropertyConfigurationManagerFactory (com.facebook.presto.spi.session.TestingSessionPropertyConfigurationManagerFactory)1 Test (org.testng.annotations.Test)1