Search in sources :

Example 11 with AllowAllAccessControl

use of io.trino.security.AllowAllAccessControl in project trino by trinodb.

the class TestRecordAccess method testStreamExists.

@Test
public void testStreamExists() {
    QualifiedObjectName name = new QualifiedObjectName("kinesis", "default", dummyStreamName);
    transaction(queryRunner.getTransactionManager(), new AllowAllAccessControl()).singleStatement().execute(SESSION, session -> {
        Optional<TableHandle> handle = queryRunner.getServer().getMetadata().getTableHandle(session, name);
        assertTrue(handle.isPresent());
    });
    log.info("Completed first test (access table handle)");
}
Also used : AllowAllAccessControl(io.trino.security.AllowAllAccessControl) TableHandle(io.trino.metadata.TableHandle) QualifiedObjectName(io.trino.metadata.QualifiedObjectName) Test(org.testng.annotations.Test)

Example 12 with AllowAllAccessControl

use of io.trino.security.AllowAllAccessControl in project trino by trinodb.

the class TestQuerySessionSupplier method createSessionSupplier.

private static QuerySessionSupplier createSessionSupplier(SqlEnvironmentConfig config) {
    TransactionManager transactionManager = createTestTransactionManager();
    Metadata metadata = testMetadataManagerBuilder().withTransactionManager(transactionManager).build();
    return new QuerySessionSupplier(metadata, new AllowAllAccessControl(), new SessionPropertyManager(), config);
}
Also used : TransactionManager(io.trino.transaction.TransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.trino.transaction.InMemoryTransactionManager.createTestTransactionManager) AllowAllAccessControl(io.trino.security.AllowAllAccessControl) Metadata(io.trino.metadata.Metadata) SessionPropertyManager(io.trino.metadata.SessionPropertyManager)

Example 13 with AllowAllAccessControl

use of io.trino.security.AllowAllAccessControl in project trino by trinodb.

the class ValuesStatsRule method getSymbolValues.

private List<Object> getSymbolValues(ValuesNode valuesNode, int symbolId, Session session, Type rowType) {
    Type symbolType = rowType.getTypeParameters().get(symbolId);
    if (UNKNOWN.equals(symbolType)) {
        // special casing for UNKNOWN as evaluateConstantExpression does not handle that
        return IntStream.range(0, valuesNode.getRowCount()).mapToObj(rowId -> null).collect(toList());
    }
    checkState(valuesNode.getRows().isPresent(), "rows is empty");
    return valuesNode.getRows().get().stream().map(row -> {
        Object rowValue = evaluateConstantExpression(row, rowType, plannerContext, session, new AllowAllAccessControl(), ImmutableMap.of());
        return readNativeValue(symbolType, (SingleRowBlock) rowValue, symbolId);
    }).collect(toList());
}
Also used : IntStream(java.util.stream.IntStream) AllowAllAccessControl(io.trino.security.AllowAllAccessControl) ExpressionInterpreter.evaluateConstantExpression(io.trino.sql.planner.ExpressionInterpreter.evaluateConstantExpression) Patterns.values(io.trino.sql.planner.plan.Patterns.values) Type(io.trino.spi.type.Type) OptionalDouble(java.util.OptionalDouble) UNKNOWN(io.trino.type.UnknownType.UNKNOWN) StatsUtil.toStatsRepresentation(io.trino.spi.statistics.StatsUtil.toStatsRepresentation) Objects.requireNonNull(java.util.Objects.requireNonNull) Symbol(io.trino.sql.planner.Symbol) RowType(io.trino.spi.type.RowType) ImmutableMap(com.google.common.collect.ImmutableMap) Lookup(io.trino.sql.planner.iterative.Lookup) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) SingleRowBlock(io.trino.spi.block.SingleRowBlock) DoubleStream(java.util.stream.DoubleStream) Preconditions.checkState(com.google.common.base.Preconditions.checkState) Objects(java.util.Objects) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Rule(io.trino.cost.ComposableStatsCalculator.Rule) Pattern(io.trino.matching.Pattern) TypeProvider(io.trino.sql.planner.TypeProvider) Optional(java.util.Optional) ValuesNode(io.trino.sql.planner.plan.ValuesNode) TypeUtils.readNativeValue(io.trino.spi.type.TypeUtils.readNativeValue) Session(io.trino.Session) PlannerContext(io.trino.sql.PlannerContext) Type(io.trino.spi.type.Type) RowType(io.trino.spi.type.RowType) AllowAllAccessControl(io.trino.security.AllowAllAccessControl) SingleRowBlock(io.trino.spi.block.SingleRowBlock)

Example 14 with AllowAllAccessControl

use of io.trino.security.AllowAllAccessControl in project trino by trinodb.

the class SimplifyCountOverConstant method isCountOverConstant.

private boolean isCountOverConstant(Session session, AggregationNode.Aggregation aggregation, Assignments inputs) {
    BoundSignature signature = aggregation.getResolvedFunction().getSignature();
    if (!signature.getName().equals("count") || signature.getArgumentTypes().size() != 1) {
        return false;
    }
    Expression argument = aggregation.getArguments().get(0);
    if (argument instanceof SymbolReference) {
        argument = inputs.get(Symbol.from(argument));
    }
    if (isEffectivelyLiteral(plannerContext, session, argument)) {
        Object value = evaluateConstantExpression(argument, ImmutableMap.of(), ImmutableSet.of(), plannerContext, session, new AllowAllAccessControl(), ImmutableSet.of(), ImmutableMap.of());
        verify(!(value instanceof Expression));
        return value != null;
    }
    return false;
}
Also used : ExpressionInterpreter.evaluateConstantExpression(io.trino.sql.planner.ExpressionInterpreter.evaluateConstantExpression) Expression(io.trino.sql.tree.Expression) SymbolReference(io.trino.sql.tree.SymbolReference) AllowAllAccessControl(io.trino.security.AllowAllAccessControl) BoundSignature(io.trino.metadata.BoundSignature)

Example 15 with AllowAllAccessControl

use of io.trino.security.AllowAllAccessControl in project trino by trinodb.

the class ExpressionUtils method getExpressionTypes.

/**
 * @deprecated Use {@link io.trino.sql.planner.TypeAnalyzer#getTypes(Session, TypeProvider, Expression)}.
 */
@Deprecated
public static Map<NodeRef<Expression>, Type> getExpressionTypes(PlannerContext plannerContext, Session session, Expression expression, TypeProvider types) {
    ExpressionAnalyzer expressionAnalyzer = ExpressionAnalyzer.createWithoutSubqueries(plannerContext, new AllowAllAccessControl(), session, types, ImmutableMap.of(), node -> new IllegalStateException("Unexpected node: " + node), WarningCollector.NOOP, false);
    expressionAnalyzer.analyze(expression, Scope.create());
    return expressionAnalyzer.getExpressionTypes();
}
Also used : AllowAllAccessControl(io.trino.security.AllowAllAccessControl) ExpressionAnalyzer(io.trino.sql.analyzer.ExpressionAnalyzer)

Aggregations

AllowAllAccessControl (io.trino.security.AllowAllAccessControl)28 Test (org.testng.annotations.Test)16 QualifiedObjectName (io.trino.metadata.QualifiedObjectName)9 TableHandle (io.trino.metadata.TableHandle)8 CatalogName (io.trino.connector.CatalogName)7 PropertyMetadata.stringProperty (io.trino.spi.session.PropertyMetadata.stringProperty)7 BeforeMethod (org.testng.annotations.BeforeMethod)7 Session (io.trino.Session)6 AbstractMockMetadata (io.trino.metadata.AbstractMockMetadata)6 TablePropertyManager (io.trino.metadata.TablePropertyManager)6 TransactionManager (io.trino.transaction.TransactionManager)6 ImmutableMap (com.google.common.collect.ImmutableMap)5 PlannerContext (io.trino.sql.PlannerContext)5 ColumnDefinition (io.trino.sql.tree.ColumnDefinition)5 CreateTable (io.trino.sql.tree.CreateTable)5 Identifier (io.trino.sql.tree.Identifier)5 Property (io.trino.sql.tree.Property)5 ImmutableList (com.google.common.collect.ImmutableList)4 Sets.immutableEnumSet (com.google.common.collect.Sets.immutableEnumSet)4 MoreFutures.getFutureValue (io.airlift.concurrent.MoreFutures.getFutureValue)4