use of com.facebook.presto.spi.session.SessionPropertyConfigurationManager.SystemSessionPropertyConfiguration 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()));
}
use of com.facebook.presto.spi.session.SessionPropertyConfigurationManager.SystemSessionPropertyConfiguration in project presto by prestodb.
the class SessionPropertyDefaults method newSessionWithDefaultProperties.
public Session newSessionWithDefaultProperties(Session session, Optional<String> queryType, Optional<ResourceGroupId> resourceGroupId) {
SessionPropertyConfigurationManager configurationManager = delegate.get();
if (configurationManager == null) {
return session;
}
SessionConfigurationContext context = new SessionConfigurationContext(session.getIdentity().getUser(), session.getSource(), session.getClientTags(), queryType, resourceGroupId, session.getClientInfo());
SystemSessionPropertyConfiguration systemPropertyConfiguration = configurationManager.getSystemSessionProperties(context);
Map<String, Map<String, String>> catalogPropertyOverrides = configurationManager.getCatalogSessionProperties(context);
return session.withDefaultProperties(systemPropertyConfiguration, catalogPropertyOverrides);
}
use of com.facebook.presto.spi.session.SessionPropertyConfigurationManager.SystemSessionPropertyConfiguration in project presto by prestodb.
the class TestFileSessionPropertyManager method assertProperties.
private static void assertProperties(Map<String, String> defaultProperties, Map<String, String> overrideProperties, SessionMatchSpec... spec) throws IOException {
try (TempFile tempFile = new TempFile()) {
Path configurationFile = tempFile.path();
Files.write(configurationFile, CODEC.toJsonBytes(Arrays.asList(spec)));
SessionPropertyConfigurationManager manager = new FileSessionPropertyManager(new FileSessionPropertyManagerConfig().setConfigFile(configurationFile.toFile()));
SystemSessionPropertyConfiguration propertyConfiguration = manager.getSystemSessionProperties(CONTEXT);
assertEquals(propertyConfiguration.systemPropertyDefaults, defaultProperties);
assertEquals(propertyConfiguration.systemPropertyOverrides, overrideProperties);
}
}
Aggregations