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");
}
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);
}
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");
}
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"));
}
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);
});
}
Aggregations