Search in sources :

Example 1 with FeaturesConfig

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

the class TestCreateMaterializedViewTask method testCreateDenyPermission.

@Test
public void testCreateDenyPermission() {
    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(), Optional.empty());
    TestingAccessControlManager accessControl = new TestingAccessControlManager(transactionManager, emptyEventListenerManager());
    accessControl.loadSystemAccessControl(AllowAllSystemAccessControl.NAME, ImmutableMap.of());
    accessControl.deny(privilege("test_mv", CREATE_MATERIALIZED_VIEW));
    StatementAnalyzerFactory statementAnalyzerFactory = createTestingStatementAnalyzerFactory(plannerContext, accessControl, new TablePropertyManager(), new AnalyzePropertyManager());
    AnalyzerFactory analyzerFactory = new AnalyzerFactory(statementAnalyzerFactory, new StatementRewrite(ImmutableSet.of()));
    assertThatThrownBy(() -> getFutureValue(new CreateMaterializedViewTask(plannerContext, accessControl, parser, analyzerFactory, materializedViewPropertyManager, new FeaturesConfig()).execute(statement, queryStateMachine, ImmutableList.of(), WarningCollector.NOOP))).isInstanceOf(AccessDeniedException.class).hasMessageContaining("Cannot create materialized view catalog.schema.test_mv");
}
Also used : AccessDeniedException(io.trino.spi.security.AccessDeniedException) CreateMaterializedView(io.trino.sql.tree.CreateMaterializedView) FeaturesConfig(io.trino.FeaturesConfig) StatementRewrite(io.trino.sql.rewrite.StatementRewrite) AllColumns(io.trino.sql.tree.AllColumns) TablePropertyManager(io.trino.metadata.TablePropertyManager) TestingAccessControlManager(io.trino.testing.TestingAccessControlManager) StatementAnalyzerFactory.createTestingStatementAnalyzerFactory(io.trino.sql.analyzer.StatementAnalyzerFactory.createTestingStatementAnalyzerFactory) StatementAnalyzerFactory(io.trino.sql.analyzer.StatementAnalyzerFactory) AnalyzePropertyManager(io.trino.metadata.AnalyzePropertyManager) AnalyzerFactory(io.trino.sql.analyzer.AnalyzerFactory) StatementAnalyzerFactory.createTestingStatementAnalyzerFactory(io.trino.sql.analyzer.StatementAnalyzerFactory.createTestingStatementAnalyzerFactory) StatementAnalyzerFactory(io.trino.sql.analyzer.StatementAnalyzerFactory) Test(org.testng.annotations.Test)

Example 2 with FeaturesConfig

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

the class TestCreateMaterializedViewTask method testCreateMaterializedViewIfNotExists.

@Test
public void testCreateMaterializedViewIfNotExists() {
    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(), Optional.empty());
    getFutureValue(new CreateMaterializedViewTask(plannerContext, new AllowAllAccessControl(), parser, analyzerFactory, materializedViewPropertyManager, new FeaturesConfig()).execute(statement, queryStateMachine, ImmutableList.of(), WarningCollector.NOOP));
    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 3 with FeaturesConfig

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

the class TestGlobalFunctionCatalog method testDuplicateFunctions.

@Test
public void testDuplicateFunctions() {
    FunctionBundle functionBundle = extractFunctions(CustomAdd.class);
    TypeOperators typeOperators = new TypeOperators();
    GlobalFunctionCatalog globalFunctionCatalog = new GlobalFunctionCatalog();
    globalFunctionCatalog.addFunctions(SystemFunctionBundle.create(new FeaturesConfig(), typeOperators, new BlockTypeOperators(typeOperators), NodeVersion.UNKNOWN));
    globalFunctionCatalog.addFunctions(functionBundle);
    assertThatThrownBy(() -> globalFunctionCatalog.addFunctions(functionBundle)).isInstanceOf(IllegalArgumentException.class).hasMessageMatching("\\QFunction already registered: custom_add(bigint,bigint):bigint\\E");
}
Also used : BlockTypeOperators(io.trino.type.BlockTypeOperators) FeaturesConfig(io.trino.FeaturesConfig) TypeOperators(io.trino.spi.type.TypeOperators) BlockTypeOperators(io.trino.type.BlockTypeOperators) Test(org.testng.annotations.Test)

Example 4 with FeaturesConfig

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

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

the class TestAnalyzer method analyze.

private Analysis analyze(Session clientSession, @Language("SQL") String query, AccessControl accessControl) {
    return transaction(transactionManager, accessControl).singleStatement().readUncommitted().execute(clientSession, session -> {
        Analyzer analyzer = createAnalyzer(session, accessControl);
        Statement statement = SQL_PARSER.createStatement(query, new ParsingOptions(new FeaturesConfig().isParseDecimalLiteralsAsDouble() ? AS_DOUBLE : AS_DECIMAL));
        return analyzer.analyze(statement);
    });
}
Also used : ParsingOptions(io.trino.sql.parser.ParsingOptions) Statement(io.trino.sql.tree.Statement) FeaturesConfig(io.trino.FeaturesConfig)

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