Search in sources :

Example 1 with SessionPropertyManager

use of io.trino.metadata.SessionPropertyManager in project trino by trinodb.

the class TestSessionPropertyDefaults method testApplyDefaultProperties.

@Test
public void testApplyDefaultProperties() {
    SessionPropertyDefaults sessionPropertyDefaults = new SessionPropertyDefaults(TEST_NODE_INFO, new AllowAllAccessControlManager());
    SessionPropertyManager sessionPropertyManager = new SessionPropertyManager();
    sessionPropertyManager.addConnectorSessionProperties(new CatalogName("testCatalog"), ImmutableList.of(PropertyMetadata.stringProperty("explicit_set", "Test property", null, false), PropertyMetadata.stringProperty("catalog_default", "Test property", null, false)));
    SessionPropertyConfigurationManagerFactory factory = new TestingSessionPropertyConfigurationManagerFactory(ImmutableMap.<String, String>builder().put(QUERY_MAX_MEMORY, // Will be overridden
    "2GB").put(QUERY_MAX_TOTAL_MEMORY, // Will remain default
    "2GB").buildOrThrow(), ImmutableMap.of("testCatalog", ImmutableMap.<String, String>builder().put("explicit_set", // Will be overridden
    "override").put("catalog_default", // Will remain default
    "catalog_default").buildOrThrow()));
    sessionPropertyDefaults.addConfigurationManagerFactory(factory);
    sessionPropertyDefaults.setConfigurationManager(factory.getName(), ImmutableMap.of());
    Session session = Session.builder(sessionPropertyManager).setQueryId(new QueryId("test_query_id")).setIdentity(Identity.ofUser("testUser")).setSystemProperty(QUERY_MAX_MEMORY, // Override this default system property
    "1GB").setSystemProperty(JOIN_DISTRIBUTION_TYPE, "partitioned").setSystemProperty(HASH_PARTITION_COUNT, "43").setCatalogSessionProperty("testCatalog", "explicit_set", // Override this default catalog property
    "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").buildOrThrow());
    assertEquals(session.getCatalogProperties(), ImmutableMap.of("testCatalog", ImmutableMap.<String, String>builder().put("explicit_set", "explicit_set").buildOrThrow()));
    session = sessionPropertyDefaults.newSessionWithDefaultProperties(session, Optional.empty(), TEST_RESOURCE_GROUP_ID);
    assertEquals(session.getSystemProperties(), ImmutableMap.<String, String>builder().put(QUERY_MAX_MEMORY, // User provided value overrides default value
    "1GB").put(JOIN_DISTRIBUTION_TYPE, // User provided value is used
    "partitioned").put(HASH_PARTITION_COUNT, // User provided value is used
    "43").put(QUERY_MAX_TOTAL_MEMORY, // Default value is used
    "2GB").buildOrThrow());
    assertEquals(session.getCatalogProperties(), ImmutableMap.of("testCatalog", ImmutableMap.<String, String>builder().put("explicit_set", // User provided value overrides default value
    "explicit_set").put("catalog_default", // Default value is used
    "catalog_default").buildOrThrow()));
}
Also used : AllowAllAccessControlManager(io.trino.testing.AllowAllAccessControlManager) QueryId(io.trino.spi.QueryId) SessionPropertyManager(io.trino.metadata.SessionPropertyManager) TestingSessionPropertyConfigurationManagerFactory(io.trino.spi.session.TestingSessionPropertyConfigurationManagerFactory) CatalogName(io.trino.connector.CatalogName) TestingSessionPropertyConfigurationManagerFactory(io.trino.spi.session.TestingSessionPropertyConfigurationManagerFactory) SessionPropertyConfigurationManagerFactory(io.trino.spi.session.SessionPropertyConfigurationManagerFactory) Session(io.trino.Session) Test(org.testng.annotations.Test)

Example 2 with SessionPropertyManager

use of io.trino.metadata.SessionPropertyManager in project trino by trinodb.

the class TestFilterHideInacessibleColumnsSession method testEnableWhenDisabledByDefault.

@Test
public void testEnableWhenDisabledByDefault() {
    FeaturesConfig featuresConfig = new FeaturesConfig();
    SessionPropertyManager sessionPropertyManager = createSessionPropertyManager(featuresConfig);
    assertThatNoException().isThrownBy(() -> sessionPropertyManager.validateSystemSessionProperty(SystemSessionProperties.HIDE_INACCESSIBLE_COLUMNS, "true"));
}
Also used : FeaturesConfig(io.trino.FeaturesConfig) SessionPropertyManager(io.trino.metadata.SessionPropertyManager) Test(org.testng.annotations.Test)

Example 3 with SessionPropertyManager

use of io.trino.metadata.SessionPropertyManager in project trino by trinodb.

the class TestAnalyzer method createAnalyzer.

private Analyzer createAnalyzer(Session session, AccessControl accessControl) {
    StatementRewrite statementRewrite = new StatementRewrite(ImmutableSet.of(new ShowQueriesRewrite(plannerContext.getMetadata(), plannerContext.getFunctionManager(), SQL_PARSER, accessControl, new SessionPropertyManager(), new SchemaPropertyManager(), new ColumnPropertyManager(), tablePropertyManager, new MaterializedViewPropertyManager())));
    StatementAnalyzerFactory statementAnalyzerFactory = createTestingStatementAnalyzerFactory(plannerContext, accessControl, tablePropertyManager, analyzePropertyManager);
    AnalyzerFactory analyzerFactory = new AnalyzerFactory(statementAnalyzerFactory, statementRewrite);
    return analyzerFactory.createAnalyzer(session, emptyList(), emptyMap(), WarningCollector.NOOP);
}
Also used : ColumnPropertyManager(io.trino.metadata.ColumnPropertyManager) StatementRewrite(io.trino.sql.rewrite.StatementRewrite) SessionPropertyManager(io.trino.metadata.SessionPropertyManager) MaterializedViewPropertyManager(io.trino.metadata.MaterializedViewPropertyManager) ShowQueriesRewrite(io.trino.sql.rewrite.ShowQueriesRewrite) SchemaPropertyManager(io.trino.metadata.SchemaPropertyManager) StatementAnalyzerFactory.createTestingStatementAnalyzerFactory(io.trino.sql.analyzer.StatementAnalyzerFactory.createTestingStatementAnalyzerFactory) StatementAnalyzerFactory.createTestingStatementAnalyzerFactory(io.trino.sql.analyzer.StatementAnalyzerFactory.createTestingStatementAnalyzerFactory)

Example 4 with SessionPropertyManager

use of io.trino.metadata.SessionPropertyManager in project trino by trinodb.

the class TestQuerySessionSupplier method createSessionSupplier.

private static QuerySessionSupplier createSessionSupplier(SqlEnvironmentConfig config) {
    TransactionManager transactionManager = createTestTransactionManager();
    Metadata metadata = testMetadataManagerBuilder().withTransactionManager(transactionManager).build();
    return new QuerySessionSupplier(metadata, new AllowAllAccessControl(), new SessionPropertyManager(), config);
}
Also used : TransactionManager(io.trino.transaction.TransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.trino.transaction.InMemoryTransactionManager.createTestTransactionManager) AllowAllAccessControl(io.trino.security.AllowAllAccessControl) Metadata(io.trino.metadata.Metadata) SessionPropertyManager(io.trino.metadata.SessionPropertyManager)

Example 5 with SessionPropertyManager

use of io.trino.metadata.SessionPropertyManager in project trino by trinodb.

the class TestAnalyzer method testTooManyGroupingElements.

@Test
public void testTooManyGroupingElements() {
    Session session = testSessionBuilder(new SessionPropertyManager(new SystemSessionProperties(new QueryManagerConfig(), new TaskManagerConfig(), new MemoryManagerConfig(), new FeaturesConfig().setMaxGroupingSets(2048), new OptimizerConfig(), new NodeMemoryConfig(), new DynamicFilterConfig(), new NodeSchedulerConfig()))).build();
    analyze(session, "SELECT a, b, c, d, e, f, g, h, i, j, k, SUM(l)" + "FROM (VALUES (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12))\n" + "t (a, b, c, d, e, f, g, h, i, j, k, l)\n" + "GROUP BY CUBE (a, b, c, d, e, f), CUBE (g, h, i, j, k)");
    assertFails(session, "SELECT a, b, c, d, e, f, g, h, i, j, k, l, SUM(m)" + "FROM (VALUES (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13))\n" + "t (a, b, c, d, e, f, g, h, i, j, k, l, m)\n" + "GROUP BY CUBE (a, b, c, d, e, f), CUBE (g, h, i, j, k, l)").hasErrorCode(TOO_MANY_GROUPING_SETS).hasMessageMatching("line 3:10: GROUP BY has 4096 grouping sets but can contain at most 2048");
    assertFails(session, "SELECT a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, " + "q, r, s, t, u, v, x, w, y, z, aa, ab, ac, ad, ae, SUM(af)" + "FROM (VALUES (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, " + "17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32))\n" + "t (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, " + "q, r, s, t, u, v, x, w, y, z, aa, ab, ac, ad, ae, af)\n" + "GROUP BY CUBE (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, " + "q, r, s, t, u, v, x, w, y, z, aa, ab, ac, ad, ae)").hasErrorCode(TOO_MANY_GROUPING_SETS).hasMessageMatching(format("line 3:10: GROUP BY has more than %s grouping sets but can contain at most 2048", Integer.MAX_VALUE));
}
Also used : OptimizerConfig(io.trino.sql.planner.OptimizerConfig) FeaturesConfig(io.trino.FeaturesConfig) SessionPropertyManager(io.trino.metadata.SessionPropertyManager) NodeSchedulerConfig(io.trino.execution.scheduler.NodeSchedulerConfig) NodeMemoryConfig(io.trino.memory.NodeMemoryConfig) QueryManagerConfig(io.trino.execution.QueryManagerConfig) TaskManagerConfig(io.trino.execution.TaskManagerConfig) MemoryManagerConfig(io.trino.memory.MemoryManagerConfig) DynamicFilterConfig(io.trino.execution.DynamicFilterConfig) Session(io.trino.Session) ConnectorSession(io.trino.spi.connector.ConnectorSession) SystemSessionProperties(io.trino.SystemSessionProperties) Test(org.testng.annotations.Test)

Aggregations

SessionPropertyManager (io.trino.metadata.SessionPropertyManager)10 Test (org.testng.annotations.Test)6 FeaturesConfig (io.trino.FeaturesConfig)5 CatalogName (io.trino.connector.CatalogName)3 Session (io.trino.Session)2 SystemSessionProperties (io.trino.SystemSessionProperties)1 DynamicFilterConfig (io.trino.execution.DynamicFilterConfig)1 QueryManagerConfig (io.trino.execution.QueryManagerConfig)1 TaskManagerConfig (io.trino.execution.TaskManagerConfig)1 NodeSchedulerConfig (io.trino.execution.scheduler.NodeSchedulerConfig)1 MemoryManagerConfig (io.trino.memory.MemoryManagerConfig)1 NodeMemoryConfig (io.trino.memory.NodeMemoryConfig)1 ColumnPropertyManager (io.trino.metadata.ColumnPropertyManager)1 MaterializedViewPropertyManager (io.trino.metadata.MaterializedViewPropertyManager)1 Metadata (io.trino.metadata.Metadata)1 SchemaPropertyManager (io.trino.metadata.SchemaPropertyManager)1 StorageManagerConfig (io.trino.plugin.raptor.legacy.storage.StorageManagerConfig)1 AllowAllAccessControl (io.trino.security.AllowAllAccessControl)1 QueryId (io.trino.spi.QueryId)1 ConnectorSession (io.trino.spi.connector.ConnectorSession)1