Search in sources :

Example 11 with FeaturesConfig

use of io.trino.FeaturesConfig in project trino by trinodb.

the class TestCreateMaterializedViewTask method testCreateMaterializedViewWithExistingView.

@Test
public void testCreateMaterializedViewWithExistingView() {
    CreateMaterializedView statement = new CreateMaterializedView(Optional.empty(), QualifiedName.of("test_mv"), simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("catalog", "schema", "mock_table"))), false, false, ImmutableList.of(), Optional.empty());
    assertTrinoExceptionThrownBy(() -> getFutureValue(new CreateMaterializedViewTask(plannerContext, new AllowAllAccessControl(), parser, analyzerFactory, materializedViewPropertyManager, new FeaturesConfig()).execute(statement, queryStateMachine, ImmutableList.of(), WarningCollector.NOOP))).hasErrorCode(ALREADY_EXISTS).hasMessage("Materialized view already exists");
    assertEquals(metadata.getCreateMaterializedViewCallCount(), 1);
}
Also used : CreateMaterializedView(io.trino.sql.tree.CreateMaterializedView) AllowAllAccessControl(io.trino.security.AllowAllAccessControl) FeaturesConfig(io.trino.FeaturesConfig) AllColumns(io.trino.sql.tree.AllColumns) Test(org.testng.annotations.Test)

Example 12 with FeaturesConfig

use of io.trino.FeaturesConfig in project trino by trinodb.

the class TestCreateMaterializedViewTask method testCreateMaterializedViewWithDefaultProperties.

@Test
public void testCreateMaterializedViewWithDefaultProperties() {
    QualifiedName materializedViewName = QualifiedName.of("catalog", "schema", "mv");
    CreateMaterializedView statement = new CreateMaterializedView(Optional.empty(), materializedViewName, simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("catalog", "schema", "mock_table"))), false, true, ImmutableList.of(// set foo to DEFAULT
    new Property(new Identifier("foo")), // set bar to DEFAULT
    new Property(new Identifier("bar"))), Optional.empty());
    getFutureValue(new CreateMaterializedViewTask(plannerContext, new AllowAllAccessControl(), parser, analyzerFactory, materializedViewPropertyManager, new FeaturesConfig()).execute(statement, queryStateMachine, ImmutableList.of(), WarningCollector.NOOP));
    Optional<MaterializedViewDefinition> definitionOptional = metadata.getMaterializedView(testSession, QualifiedObjectName.valueOf(materializedViewName.toString()));
    assertThat(definitionOptional).isPresent();
    Map<String, Object> properties = definitionOptional.get().getProperties();
    assertThat(properties.get("foo")).isEqualTo(DEFAULT_MATERIALIZED_VIEW_FOO_PROPERTY_VALUE);
    assertThat(properties.get("bar")).isEqualTo(DEFAULT_MATERIALIZED_VIEW_BAR_PROPERTY_VALUE);
}
Also used : FeaturesConfig(io.trino.FeaturesConfig) QualifiedName(io.trino.sql.tree.QualifiedName) AllColumns(io.trino.sql.tree.AllColumns) CreateMaterializedView(io.trino.sql.tree.CreateMaterializedView) Identifier(io.trino.sql.tree.Identifier) MaterializedViewDefinition(io.trino.metadata.MaterializedViewDefinition) AllowAllAccessControl(io.trino.security.AllowAllAccessControl) Property(io.trino.sql.tree.Property) PropertyMetadata.integerProperty(io.trino.spi.session.PropertyMetadata.integerProperty) PropertyMetadata.stringProperty(io.trino.spi.session.PropertyMetadata.stringProperty) Test(org.testng.annotations.Test)

Example 13 with FeaturesConfig

use of io.trino.FeaturesConfig in project trino by trinodb.

the class TestCreateMaterializedViewTask method testCreateMaterializedViewWithInvalidProperty.

@Test
public void testCreateMaterializedViewWithInvalidProperty() {
    CreateMaterializedView statement = new CreateMaterializedView(Optional.empty(), QualifiedName.of("test_mv"), simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("catalog", "schema", "mock_table"))), false, true, ImmutableList.of(new Property(new Identifier("baz"), new StringLiteral("abc"))), Optional.empty());
    assertTrinoExceptionThrownBy(() -> getFutureValue(new CreateMaterializedViewTask(plannerContext, new AllowAllAccessControl(), parser, analyzerFactory, materializedViewPropertyManager, new FeaturesConfig()).execute(statement, queryStateMachine, ImmutableList.of(), WarningCollector.NOOP))).hasErrorCode(INVALID_MATERIALIZED_VIEW_PROPERTY).hasMessage("Catalog 'catalog' materialized view property 'baz' does not exist");
    assertEquals(metadata.getCreateMaterializedViewCallCount(), 0);
}
Also used : CreateMaterializedView(io.trino.sql.tree.CreateMaterializedView) Identifier(io.trino.sql.tree.Identifier) StringLiteral(io.trino.sql.tree.StringLiteral) AllowAllAccessControl(io.trino.security.AllowAllAccessControl) FeaturesConfig(io.trino.FeaturesConfig) AllColumns(io.trino.sql.tree.AllColumns) Property(io.trino.sql.tree.Property) PropertyMetadata.integerProperty(io.trino.spi.session.PropertyMetadata.integerProperty) PropertyMetadata.stringProperty(io.trino.spi.session.PropertyMetadata.stringProperty) Test(org.testng.annotations.Test)

Example 14 with FeaturesConfig

use of io.trino.FeaturesConfig in project trino by trinodb.

the class TestBinaryFileSpiller method setUp.

@BeforeMethod
public void setUp() {
    spillerStats = new SpillerStats();
    FeaturesConfig featuresConfig = new FeaturesConfig();
    featuresConfig.setSpillerSpillPaths(spillPath.getAbsolutePath());
    featuresConfig.setSpillMaxUsedSpaceThreshold(1.0);
    NodeSpillConfig nodeSpillConfig = new NodeSpillConfig();
    BlockEncodingSerde blockEncodingSerde = new TestingBlockEncodingSerde();
    singleStreamSpillerFactory = new FileSingleStreamSpillerFactory(blockEncodingSerde, spillerStats, featuresConfig, nodeSpillConfig);
    factory = new GenericSpillerFactory(singleStreamSpillerFactory);
    PagesSerdeFactory pagesSerdeFactory = new PagesSerdeFactory(blockEncodingSerde, nodeSpillConfig.isSpillCompressionEnabled());
    pagesSerde = pagesSerdeFactory.createPagesSerde();
    memoryContext = newSimpleAggregatedMemoryContext();
}
Also used : PagesSerdeFactory(io.trino.execution.buffer.PagesSerdeFactory) TestingBlockEncodingSerde(io.trino.spi.block.TestingBlockEncodingSerde) FeaturesConfig(io.trino.FeaturesConfig) TestingBlockEncodingSerde(io.trino.spi.block.TestingBlockEncodingSerde) BlockEncodingSerde(io.trino.spi.block.BlockEncodingSerde) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 15 with FeaturesConfig

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

FeaturesConfig (io.trino.FeaturesConfig)21 Test (org.testng.annotations.Test)13 SessionPropertyManager (io.trino.metadata.SessionPropertyManager)5 AllColumns (io.trino.sql.tree.AllColumns)5 CreateMaterializedView (io.trino.sql.tree.CreateMaterializedView)5 AllowAllAccessControl (io.trino.security.AllowAllAccessControl)4 TypeOperators (io.trino.spi.type.TypeOperators)4 TpchConnectorFactory (io.trino.plugin.tpch.TpchConnectorFactory)3 LocalQueryRunner (io.trino.testing.LocalQueryRunner)3 BlockTypeOperators (io.trino.type.BlockTypeOperators)3 Session (io.trino.Session)2 TestingBlockEncodingSerde (io.trino.spi.block.TestingBlockEncodingSerde)2 PropertyMetadata.integerProperty (io.trino.spi.session.PropertyMetadata.integerProperty)2 PropertyMetadata.stringProperty (io.trino.spi.session.PropertyMetadata.stringProperty)2 Identifier (io.trino.sql.tree.Identifier)2 Property (io.trino.sql.tree.Property)2 BeforeClass (org.testng.annotations.BeforeClass)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 TestingHttpClient (io.airlift.http.client.testing.TestingHttpClient)1 NodeInfo (io.airlift.node.NodeInfo)1