Search in sources :

Example 1 with TestingSessionPropertyConfigurationManagerFactory

use of io.prestosql.spi.session.TestingSessionPropertyConfigurationManagerFactory in project hetu-core by openlookeng.

the class TestSessionPropertyDefaults method testApplyDefaultProperties.

@Test
public void testApplyDefaultProperties() {
    SessionPropertyDefaults sessionPropertyDefaults = new SessionPropertyDefaults(TEST_NODE_INFO);
    SessionPropertyConfigurationManagerFactory factory = new TestingSessionPropertyConfigurationManagerFactory(ImmutableMap.<String, String>builder().put(QUERY_MAX_MEMORY, "override").put("system_default", "system_default").build(), 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").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").build());
    assertEquals(session.getUnprocessedCatalogProperties(), ImmutableMap.of("testCatalog", ImmutableMap.<String, String>builder().put("explicit_set", "explicit_set").build()));
    session = sessionPropertyDefaults.newSessionWithDefaultProperties(session, Optional.empty(), 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").build());
    assertEquals(session.getUnprocessedCatalogProperties(), ImmutableMap.of("testCatalog", ImmutableMap.<String, String>builder().put("explicit_set", "explicit_set").put("catalog_default", "catalog_default").build()));
}
Also used : QueryId(io.prestosql.spi.QueryId) TestingSessionPropertyConfigurationManagerFactory(io.prestosql.spi.session.TestingSessionPropertyConfigurationManagerFactory) SessionPropertyManager(io.prestosql.metadata.SessionPropertyManager) SessionPropertyConfigurationManagerFactory(io.prestosql.spi.session.SessionPropertyConfigurationManagerFactory) TestingSessionPropertyConfigurationManagerFactory(io.prestosql.spi.session.TestingSessionPropertyConfigurationManagerFactory) Identity(io.prestosql.spi.security.Identity) Session(io.prestosql.Session) Test(org.testng.annotations.Test)

Aggregations

Session (io.prestosql.Session)1 SessionPropertyManager (io.prestosql.metadata.SessionPropertyManager)1 QueryId (io.prestosql.spi.QueryId)1 Identity (io.prestosql.spi.security.Identity)1 SessionPropertyConfigurationManagerFactory (io.prestosql.spi.session.SessionPropertyConfigurationManagerFactory)1 TestingSessionPropertyConfigurationManagerFactory (io.prestosql.spi.session.TestingSessionPropertyConfigurationManagerFactory)1 Test (org.testng.annotations.Test)1