use of io.trino.security.AllowAllAccessControl in project trino by trinodb.
the class TestCreateViewTask method setUp.
@Override
@BeforeMethod
public void setUp() {
super.setUp();
parser = new SqlParser();
analyzerFactory = new AnalyzerFactory(createTestingStatementAnalyzerFactory(plannerContext, new AllowAllAccessControl(), new TablePropertyManager(), new AnalyzePropertyManager()), new StatementRewrite(ImmutableSet.of()));
QualifiedObjectName tableName = qualifiedObjectName("mock_table");
metadata.createTable(testSession, CATALOG_NAME, someTable(tableName), false);
}
use of io.trino.security.AllowAllAccessControl in project trino by trinodb.
the class BaseDataDefinitionTaskTest method setUp.
@BeforeMethod
public void setUp() {
queryRunner = LocalQueryRunner.create(TEST_SESSION);
transactionManager = queryRunner.getTransactionManager();
queryRunner.createCatalog(CATALOG_NAME, MockConnectorFactory.create("initial"), ImmutableMap.of());
testSession = testSessionBuilder().build();
metadata = new MockMetadata(new CatalogName(CATALOG_NAME));
plannerContext = plannerContextBuilder().withMetadata(metadata).build();
materializedViewPropertyManager = new MaterializedViewPropertyManager();
materializedViewPropertyManager.addProperties(new CatalogName(CATALOG_NAME), ImmutableList.of(longProperty(MATERIALIZED_VIEW_PROPERTY_1_NAME, "property 1", MATERIALIZED_VIEW_PROPERTY_1_DEFAULT_VALUE, false), stringProperty(MATERIALIZED_VIEW_PROPERTY_2_NAME, "property 2", MATERIALIZED_VIEW_PROPERTY_2_DEFAULT_VALUE, false)));
queryStateMachine = stateMachine(transactionManager, createTestMetadataManager(), new AllowAllAccessControl(), testSession);
}
use of io.trino.security.AllowAllAccessControl in project trino by trinodb.
the class ExpressionTestUtils method resolveFunctionCalls.
public static Expression resolveFunctionCalls(PlannerContext plannerContext, Session session, TypeProvider typeProvider, Expression expression, Scope scope) {
ExpressionAnalyzer analyzer = ExpressionAnalyzer.createWithoutSubqueries(plannerContext, new AllowAllAccessControl(), session, typeProvider, ImmutableMap.of(), node -> semanticException(EXPRESSION_NOT_CONSTANT, node, "Constant expression cannot contain a subquery"), WarningCollector.NOOP, false);
analyzer.analyze(expression, scope);
return ExpressionTreeRewriter.rewriteWith(new ExpressionRewriter<>() {
@Override
public Expression rewriteFunctionCall(FunctionCall node, Void context, ExpressionTreeRewriter<Void> treeRewriter) {
ResolvedFunction resolvedFunction = analyzer.getResolvedFunctions().get(NodeRef.of(node));
checkArgument(resolvedFunction != null, "Function has not been analyzed: %s", node);
FunctionCall rewritten = treeRewriter.defaultRewrite(node, context);
FunctionCall newFunctionCall = new FunctionCall(rewritten.getLocation(), resolvedFunction.toQualifiedName(), rewritten.getWindow(), rewritten.getFilter(), rewritten.getOrderBy(), rewritten.isDistinct(), rewritten.getNullTreatment(), rewritten.getProcessingMode(), rewritten.getArguments());
return coerceIfNecessary(node, newFunctionCall);
}
@Override
protected Expression rewriteExpression(Expression node, Void context, ExpressionTreeRewriter<Void> treeRewriter) {
Expression rewrittenExpression = treeRewriter.defaultRewrite(node, context);
rewrittenExpression = coerceIfNecessary(node, rewrittenExpression);
return rewrittenExpression;
}
private Expression coerceIfNecessary(Expression originalExpression, Expression rewrittenExpression) {
// cast expression if coercion is registered
Type coercion = analyzer.getExpressionCoercions().get(NodeRef.of(originalExpression));
if (coercion != null) {
rewrittenExpression = new Cast(rewrittenExpression, toSqlType(coercion), false, analyzer.getTypeOnlyCoercions().contains(NodeRef.of(originalExpression)));
}
return rewrittenExpression;
}
}, expression);
}
use of io.trino.security.AllowAllAccessControl in project trino by trinodb.
the class TestKuduIntegrationDynamicFilter method testIncompleteDynamicFilterTimeout.
@Test(timeOut = 30_000)
public void testIncompleteDynamicFilterTimeout() throws Exception {
QueryRunner runner = getQueryRunner();
TransactionManager transactionManager = runner.getTransactionManager();
TransactionId transactionId = transactionManager.beginTransaction(false);
Session session = Session.builder(getSession()).setCatalogSessionProperty("kudu", "dynamic_filtering_wait_timeout", "1s").build().beginTransactionId(transactionId, transactionManager, new AllowAllAccessControl());
QualifiedObjectName tableName = new QualifiedObjectName("kudu", "tpch", "orders");
Optional<TableHandle> tableHandle = runner.getMetadata().getTableHandle(session, tableName);
assertTrue(tableHandle.isPresent());
SplitSource splitSource = runner.getSplitManager().getSplits(session, tableHandle.get(), UNGROUPED_SCHEDULING, new IncompleteDynamicFilter(), alwaysTrue());
List<Split> splits = new ArrayList<>();
while (!splitSource.isFinished()) {
splits.addAll(splitSource.getNextBatch(NOT_PARTITIONED, Lifespan.taskWide(), 1000).get().getSplits());
}
splitSource.close();
assertFalse(splits.isEmpty());
}
use of io.trino.security.AllowAllAccessControl in project trino by trinodb.
the class TestMinimalFunctionality method testStreamExists.
@Test
public void testStreamExists() {
QualifiedObjectName name = new QualifiedObjectName("kinesis", "default", streamName);
transaction(queryRunner.getTransactionManager(), new AllowAllAccessControl()).singleStatement().execute(SESSION, session -> {
Optional<TableHandle> handle = queryRunner.getServer().getMetadata().getTableHandle(session, name);
assertTrue(handle.isPresent());
});
}
Aggregations