Search in sources :

Example 1 with NodeMemoryConfig

use of io.trino.memory.NodeMemoryConfig in project trino by trinodb.

the class TestSqlTaskManager method testSessionPropertyMemoryLimitOverride.

@Test
public void testSessionPropertyMemoryLimitOverride() {
    NodeMemoryConfig memoryConfig = new NodeMemoryConfig().setMaxQueryMemoryPerNode(DataSize.ofBytes(3));
    try (SqlTaskManager sqlTaskManager = createSqlTaskManager(new TaskManagerConfig(), memoryConfig)) {
        TaskId reduceLimitsId = new TaskId(new StageId("q1", 0), 1, 0);
        TaskId increaseLimitsId = new TaskId(new StageId("q2", 0), 1, 0);
        QueryContext reducesLimitsContext = sqlTaskManager.getQueryContext(reduceLimitsId.getQueryId());
        QueryContext attemptsIncreaseContext = sqlTaskManager.getQueryContext(increaseLimitsId.getQueryId());
        // not initialized with a task update yet
        assertFalse(reducesLimitsContext.isMemoryLimitsInitialized());
        assertEquals(reducesLimitsContext.getMaxUserMemory(), memoryConfig.getMaxQueryMemoryPerNode().toBytes());
        assertFalse(attemptsIncreaseContext.isMemoryLimitsInitialized());
        assertEquals(attemptsIncreaseContext.getMaxUserMemory(), memoryConfig.getMaxQueryMemoryPerNode().toBytes());
        // memory limits reduced by session properties
        sqlTaskManager.updateTask(testSessionBuilder().setSystemProperty(QUERY_MAX_MEMORY_PER_NODE, "1B").build(), reduceLimitsId, Optional.of(PLAN_FRAGMENT), ImmutableList.of(new SplitAssignment(TABLE_SCAN_NODE_ID, ImmutableSet.of(SPLIT), true)), createInitialEmptyOutputBuffers(PARTITIONED).withBuffer(OUT, 0).withNoMoreBufferIds(), ImmutableMap.of());
        assertTrue(reducesLimitsContext.isMemoryLimitsInitialized());
        assertEquals(reducesLimitsContext.getMaxUserMemory(), 1);
        // memory limits not increased by session properties
        sqlTaskManager.updateTask(testSessionBuilder().setSystemProperty(QUERY_MAX_MEMORY_PER_NODE, "10B").build(), increaseLimitsId, Optional.of(PLAN_FRAGMENT), ImmutableList.of(new SplitAssignment(TABLE_SCAN_NODE_ID, ImmutableSet.of(SPLIT), true)), createInitialEmptyOutputBuffers(PARTITIONED).withBuffer(OUT, 0).withNoMoreBufferIds(), ImmutableMap.of());
        assertTrue(attemptsIncreaseContext.isMemoryLimitsInitialized());
        assertEquals(attemptsIncreaseContext.getMaxUserMemory(), memoryConfig.getMaxQueryMemoryPerNode().toBytes());
    }
}
Also used : NodeMemoryConfig(io.trino.memory.NodeMemoryConfig) QueryContext(io.trino.memory.QueryContext) Test(org.testng.annotations.Test)

Example 2 with NodeMemoryConfig

use of io.trino.memory.NodeMemoryConfig 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

NodeMemoryConfig (io.trino.memory.NodeMemoryConfig)2 Test (org.testng.annotations.Test)2 FeaturesConfig (io.trino.FeaturesConfig)1 Session (io.trino.Session)1 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 QueryContext (io.trino.memory.QueryContext)1 SessionPropertyManager (io.trino.metadata.SessionPropertyManager)1 ConnectorSession (io.trino.spi.connector.ConnectorSession)1 OptimizerConfig (io.trino.sql.planner.OptimizerConfig)1