Search in sources :

Example 6 with SessionPropertyManager

use of io.prestosql.metadata.SessionPropertyManager 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)

Example 7 with SessionPropertyManager

use of io.prestosql.metadata.SessionPropertyManager in project hetu-core by openlookeng.

the class TestQuerySessionSupplier method testInvalidTimeZone.

@Test(expectedExceptions = PrestoException.class)
public void testInvalidTimeZone() {
    HttpServletRequest request = new MockHttpServletRequest(ImmutableListMultimap.<String, String>builder().put(PRESTO_USER, "testUser").put(PRESTO_TIME_ZONE, "unknown_timezone").build(), "testRemote");
    HttpRequestSessionContext context = new HttpRequestSessionContext(request, user -> ImmutableSet.of());
    QuerySessionSupplier sessionSupplier = new QuerySessionSupplier(createTestTransactionManager(), new AllowAllAccessControl(), new SessionPropertyManager(), new SqlEnvironmentConfig());
    sessionSupplier.createSession(new QueryId("test_query_id"), context);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) QueryId(io.prestosql.spi.QueryId) SessionPropertyManager(io.prestosql.metadata.SessionPropertyManager) SqlEnvironmentConfig(io.prestosql.sql.SqlEnvironmentConfig) Test(org.testng.annotations.Test)

Example 8 with SessionPropertyManager

use of io.prestosql.metadata.SessionPropertyManager in project hetu-core by openlookeng.

the class SystemConnectorSessionUtil method toSession.

// this does not preserve any connector properties (for the system connector)
public static Session toSession(ConnectorTransactionHandle transactionHandle, ConnectorSession session) {
    TransactionId transactionId = ((GlobalSystemTransactionHandle) transactionHandle).getTransactionId();
    ConnectorIdentity connectorIdentity = session.getIdentity();
    Identity identity = new Identity(connectorIdentity.getUser(), connectorIdentity.getPrincipal());
    return Session.builder(new SessionPropertyManager(SYSTEM_SESSION_PROPERTIES)).setQueryId(new QueryId(session.getQueryId())).setTransactionId(transactionId).setCatalog("catalog").setSchema("schema").setPath(new SqlPath(Optional.of("path"))).setIdentity(identity).setTimeZoneKey(session.getTimeZoneKey()).setLocale(session.getLocale()).setStartTime(session.getStartTime()).build();
}
Also used : SqlPath(io.prestosql.sql.SqlPath) QueryId(io.prestosql.spi.QueryId) SessionPropertyManager(io.prestosql.metadata.SessionPropertyManager) ConnectorIdentity(io.prestosql.spi.security.ConnectorIdentity) ConnectorIdentity(io.prestosql.spi.security.ConnectorIdentity) Identity(io.prestosql.spi.security.Identity) TransactionId(io.prestosql.transaction.TransactionId)

Example 9 with SessionPropertyManager

use of io.prestosql.metadata.SessionPropertyManager in project hetu-core by openlookeng.

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").setSystemProperty(ENABLE_DYNAMIC_FILTERING, "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().getFunctionAndTypeManager().registerBuiltInFunctions(CUSTOM_FUNCTIONS);
    SessionPropertyManager sessionPropertyManager = localQueryRunner.getMetadata().getSessionPropertyManager();
    sessionPropertyManager.addSystemSessionProperties(TEST_SYSTEM_PROPERTIES);
    sessionPropertyManager.addConnectorSessionProperties(new CatalogName(TESTING_CATALOG), TEST_CATALOG_PROPERTIES);
    return localQueryRunner;
}
Also used : TpchConnectorFactory(io.prestosql.plugin.tpch.TpchConnectorFactory) SessionPropertyManager(io.prestosql.metadata.SessionPropertyManager) CatalogName(io.prestosql.spi.connector.CatalogName) LocalQueryRunner(io.prestosql.testing.LocalQueryRunner) Session(io.prestosql.Session)

Aggregations

SessionPropertyManager (io.prestosql.metadata.SessionPropertyManager)9 Session (io.prestosql.Session)7 QueryId (io.prestosql.spi.QueryId)5 Identity (io.prestosql.spi.security.Identity)3 Test (org.testng.annotations.Test)3 TpchConnectorFactory (io.prestosql.plugin.tpch.TpchConnectorFactory)2 AllowAllAccessControl (io.prestosql.security.AllowAllAccessControl)2 PrestoException (io.prestosql.spi.PrestoException)2 CatalogName (io.prestosql.spi.connector.CatalogName)2 SqlEnvironmentConfig (io.prestosql.sql.SqlEnvironmentConfig)2 LocalQueryRunner (io.prestosql.testing.LocalQueryRunner)2 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 MoreExecutors.directExecutor (com.google.common.util.concurrent.MoreExecutors.directExecutor)1 Inject (com.google.inject.Inject)1 BoundedExecutor (io.airlift.concurrent.BoundedExecutor)1 Logger (io.airlift.log.Logger)1 DataSize (io.airlift.units.DataSize)1