Search in sources :

Example 6 with VARCHAR

use of io.trino.spi.type.VarcharType.VARCHAR in project trino by trinodb.

the class TestPushTopNIntoTableScan method testPushPartialTopNIntoTableScan.

@Test
public void testPushPartialTopNIntoTableScan() {
    try (RuleTester ruleTester = defaultRuleTester()) {
        MockConnectorTableHandle connectorHandle = new MockConnectorTableHandle(TEST_SCHEMA_TABLE);
        // make the mock connector return a new connectorHandle
        MockConnectorFactory.ApplyTopN applyTopN = (session, handle, topNCount, sortItems, tableAssignments) -> Optional.of(new TopNApplicationResult<>(connectorHandle, true, false));
        MockConnectorFactory mockFactory = createMockFactory(assignments, Optional.of(applyTopN));
        ruleTester.getQueryRunner().createCatalog(MOCK_CATALOG, mockFactory, ImmutableMap.of());
        ruleTester.assertThat(new PushTopNIntoTableScan(ruleTester.getMetadata())).on(p -> {
            Symbol dimension = p.symbol(dimensionName, VARCHAR);
            Symbol metric = p.symbol(metricName, BIGINT);
            return p.topN(1, ImmutableList.of(dimension), TopNNode.Step.PARTIAL, p.tableScan(TEST_TABLE_HANDLE, ImmutableList.of(dimension, metric), ImmutableMap.of(dimension, dimensionColumn, metric, metricColumn)));
        }).withSession(MOCK_SESSION).matches(tableScan(connectorHandle::equals, TupleDomain.all(), new HashMap<>()));
    }
}
Also used : ColumnMetadata(io.trino.spi.connector.ColumnMetadata) TopNApplicationResult(io.trino.spi.connector.TopNApplicationResult) Test(org.testng.annotations.Test) HashMap(java.util.HashMap) CatalogName(io.trino.connector.CatalogName) VARCHAR(io.trino.spi.type.VarcharType.VARCHAR) ImmutableList(com.google.common.collect.ImmutableList) MockConnectorFactory(io.trino.connector.MockConnectorFactory) PlanMatchPattern.sort(io.trino.sql.planner.assertions.PlanMatchPattern.sort) ConnectorTableHandle(io.trino.spi.connector.ConnectorTableHandle) Map(java.util.Map) ColumnHandle(io.trino.spi.connector.ColumnHandle) ASCENDING(io.trino.sql.tree.SortItem.Ordering.ASCENDING) Symbol(io.trino.sql.planner.Symbol) TpchColumnHandle(io.trino.plugin.tpch.TpchColumnHandle) RuleTester.defaultRuleTester(io.trino.sql.planner.iterative.rule.test.RuleTester.defaultRuleTester) ImmutableMap(com.google.common.collect.ImmutableMap) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) TopNNode(io.trino.sql.planner.plan.TopNNode) RuleTester(io.trino.sql.planner.iterative.rule.test.RuleTester) PlanMatchPattern.topN(io.trino.sql.planner.assertions.PlanMatchPattern.topN) TupleDomain(io.trino.spi.predicate.TupleDomain) SchemaTableName(io.trino.spi.connector.SchemaTableName) FIRST(io.trino.sql.tree.SortItem.NullOrdering.FIRST) MockConnectorTableHandle(io.trino.connector.MockConnectorTableHandle) List(java.util.List) TestingSession.testSessionBuilder(io.trino.testing.TestingSession.testSessionBuilder) TableHandle(io.trino.metadata.TableHandle) BIGINT(io.trino.spi.type.BigintType.BIGINT) Optional(java.util.Optional) PlanMatchPattern.tableScan(io.trino.sql.planner.assertions.PlanMatchPattern.tableScan) Session(io.trino.Session) ConnectorTransactionHandle(io.trino.spi.connector.ConnectorTransactionHandle) MockConnectorFactory(io.trino.connector.MockConnectorFactory) HashMap(java.util.HashMap) RuleTester.defaultRuleTester(io.trino.sql.planner.iterative.rule.test.RuleTester.defaultRuleTester) RuleTester(io.trino.sql.planner.iterative.rule.test.RuleTester) MockConnectorTableHandle(io.trino.connector.MockConnectorTableHandle) Symbol(io.trino.sql.planner.Symbol) Test(org.testng.annotations.Test)

Example 7 with VARCHAR

use of io.trino.spi.type.VarcharType.VARCHAR in project trino by trinodb.

the class TestPushTopNIntoTableScan method testPushSingleTopNIntoTableScanNotGuaranteed.

@Test
public void testPushSingleTopNIntoTableScanNotGuaranteed() {
    try (RuleTester ruleTester = defaultRuleTester()) {
        MockConnectorTableHandle connectorHandle = new MockConnectorTableHandle(TEST_SCHEMA_TABLE);
        // make the mock connector return a new connectorHandle
        MockConnectorFactory.ApplyTopN applyTopN = (session, handle, topNCount, sortItems, tableAssignments) -> Optional.of(new TopNApplicationResult<>(connectorHandle, false, false));
        MockConnectorFactory mockFactory = createMockFactory(assignments, Optional.of(applyTopN));
        ruleTester.getQueryRunner().createCatalog(MOCK_CATALOG, mockFactory, ImmutableMap.of());
        ruleTester.assertThat(new PushTopNIntoTableScan(ruleTester.getMetadata())).on(p -> {
            Symbol dimension = p.symbol(dimensionName, VARCHAR);
            Symbol metric = p.symbol(metricName, BIGINT);
            return p.topN(1, ImmutableList.of(dimension), p.tableScan(TEST_TABLE_HANDLE, ImmutableList.of(dimension, metric), ImmutableMap.of(dimension, dimensionColumn, metric, metricColumn)));
        }).withSession(MOCK_SESSION).matches(topN(1, ImmutableList.of(sort(dimensionName, ASCENDING, FIRST)), TopNNode.Step.SINGLE, tableScan(connectorHandle::equals, TupleDomain.all(), ImmutableMap.of(dimensionName, dimensionColumn::equals, metricName, metricColumn::equals))));
    }
}
Also used : ColumnMetadata(io.trino.spi.connector.ColumnMetadata) TopNApplicationResult(io.trino.spi.connector.TopNApplicationResult) Test(org.testng.annotations.Test) HashMap(java.util.HashMap) CatalogName(io.trino.connector.CatalogName) VARCHAR(io.trino.spi.type.VarcharType.VARCHAR) ImmutableList(com.google.common.collect.ImmutableList) MockConnectorFactory(io.trino.connector.MockConnectorFactory) PlanMatchPattern.sort(io.trino.sql.planner.assertions.PlanMatchPattern.sort) ConnectorTableHandle(io.trino.spi.connector.ConnectorTableHandle) Map(java.util.Map) ColumnHandle(io.trino.spi.connector.ColumnHandle) ASCENDING(io.trino.sql.tree.SortItem.Ordering.ASCENDING) Symbol(io.trino.sql.planner.Symbol) TpchColumnHandle(io.trino.plugin.tpch.TpchColumnHandle) RuleTester.defaultRuleTester(io.trino.sql.planner.iterative.rule.test.RuleTester.defaultRuleTester) ImmutableMap(com.google.common.collect.ImmutableMap) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) TopNNode(io.trino.sql.planner.plan.TopNNode) RuleTester(io.trino.sql.planner.iterative.rule.test.RuleTester) PlanMatchPattern.topN(io.trino.sql.planner.assertions.PlanMatchPattern.topN) TupleDomain(io.trino.spi.predicate.TupleDomain) SchemaTableName(io.trino.spi.connector.SchemaTableName) FIRST(io.trino.sql.tree.SortItem.NullOrdering.FIRST) MockConnectorTableHandle(io.trino.connector.MockConnectorTableHandle) List(java.util.List) TestingSession.testSessionBuilder(io.trino.testing.TestingSession.testSessionBuilder) TableHandle(io.trino.metadata.TableHandle) BIGINT(io.trino.spi.type.BigintType.BIGINT) Optional(java.util.Optional) PlanMatchPattern.tableScan(io.trino.sql.planner.assertions.PlanMatchPattern.tableScan) Session(io.trino.Session) ConnectorTransactionHandle(io.trino.spi.connector.ConnectorTransactionHandle) MockConnectorFactory(io.trino.connector.MockConnectorFactory) RuleTester.defaultRuleTester(io.trino.sql.planner.iterative.rule.test.RuleTester.defaultRuleTester) RuleTester(io.trino.sql.planner.iterative.rule.test.RuleTester) MockConnectorTableHandle(io.trino.connector.MockConnectorTableHandle) Symbol(io.trino.sql.planner.Symbol) Test(org.testng.annotations.Test)

Example 8 with VARCHAR

use of io.trino.spi.type.VarcharType.VARCHAR in project trino by trinodb.

the class TestPushTopNIntoTableScan method testPushFinalTopNIntoTableScan.

/**
 * Ensure FINAL TopN can be pushed into table scan.
 * <p>
 * In case of TopN over outer join, TopN may become eligible for push down
 * only after PARTIAL TopN was pushed down and only then the join was
 * pushed down as well -- the connector may decide to accept Join pushdown
 * only after it learns there is TopN in play which limits results size.
 * <p>
 * Thus the optimization sequence can be:
 * <ol>
 * <li>Try to push Join into Table Scan -- connector rejects that (e.g. too big data set size)
 * <li>Create FINAL/PARTIAL TopN
 * <li>Push PARTIAL TopN through Outer Join
 * <li>Push PARTIAL TopN into Table Scan -- connector accepts that.
 * <li>Push Join into Table Scan -- connector now accepts join pushdown.
 * <li>Push FINAL TopN into Table Scan
 * </ol>
 */
@Test
public void testPushFinalTopNIntoTableScan() {
    try (RuleTester ruleTester = defaultRuleTester()) {
        MockConnectorTableHandle connectorHandle = new MockConnectorTableHandle(TEST_SCHEMA_TABLE);
        // make the mock connector return a new connectorHandle
        MockConnectorFactory.ApplyTopN applyTopN = (session, handle, topNCount, sortItems, tableAssignments) -> Optional.of(new TopNApplicationResult<>(connectorHandle, true, false));
        MockConnectorFactory mockFactory = createMockFactory(assignments, Optional.of(applyTopN));
        ruleTester.getQueryRunner().createCatalog(MOCK_CATALOG, mockFactory, ImmutableMap.of());
        ruleTester.assertThat(new PushTopNIntoTableScan(ruleTester.getMetadata())).on(p -> {
            Symbol dimension = p.symbol(dimensionName, VARCHAR);
            Symbol metric = p.symbol(metricName, BIGINT);
            return p.topN(1, ImmutableList.of(dimension), TopNNode.Step.FINAL, p.tableScan(TEST_TABLE_HANDLE, ImmutableList.of(dimension, metric), ImmutableMap.of(dimension, dimensionColumn, metric, metricColumn)));
        }).withSession(MOCK_SESSION).matches(tableScan(connectorHandle::equals, TupleDomain.all(), new HashMap<>()));
    }
}
Also used : ColumnMetadata(io.trino.spi.connector.ColumnMetadata) TopNApplicationResult(io.trino.spi.connector.TopNApplicationResult) Test(org.testng.annotations.Test) HashMap(java.util.HashMap) CatalogName(io.trino.connector.CatalogName) VARCHAR(io.trino.spi.type.VarcharType.VARCHAR) ImmutableList(com.google.common.collect.ImmutableList) MockConnectorFactory(io.trino.connector.MockConnectorFactory) PlanMatchPattern.sort(io.trino.sql.planner.assertions.PlanMatchPattern.sort) ConnectorTableHandle(io.trino.spi.connector.ConnectorTableHandle) Map(java.util.Map) ColumnHandle(io.trino.spi.connector.ColumnHandle) ASCENDING(io.trino.sql.tree.SortItem.Ordering.ASCENDING) Symbol(io.trino.sql.planner.Symbol) TpchColumnHandle(io.trino.plugin.tpch.TpchColumnHandle) RuleTester.defaultRuleTester(io.trino.sql.planner.iterative.rule.test.RuleTester.defaultRuleTester) ImmutableMap(com.google.common.collect.ImmutableMap) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) TopNNode(io.trino.sql.planner.plan.TopNNode) RuleTester(io.trino.sql.planner.iterative.rule.test.RuleTester) PlanMatchPattern.topN(io.trino.sql.planner.assertions.PlanMatchPattern.topN) TupleDomain(io.trino.spi.predicate.TupleDomain) SchemaTableName(io.trino.spi.connector.SchemaTableName) FIRST(io.trino.sql.tree.SortItem.NullOrdering.FIRST) MockConnectorTableHandle(io.trino.connector.MockConnectorTableHandle) List(java.util.List) TestingSession.testSessionBuilder(io.trino.testing.TestingSession.testSessionBuilder) TableHandle(io.trino.metadata.TableHandle) BIGINT(io.trino.spi.type.BigintType.BIGINT) Optional(java.util.Optional) PlanMatchPattern.tableScan(io.trino.sql.planner.assertions.PlanMatchPattern.tableScan) Session(io.trino.Session) ConnectorTransactionHandle(io.trino.spi.connector.ConnectorTransactionHandle) MockConnectorFactory(io.trino.connector.MockConnectorFactory) HashMap(java.util.HashMap) RuleTester.defaultRuleTester(io.trino.sql.planner.iterative.rule.test.RuleTester.defaultRuleTester) RuleTester(io.trino.sql.planner.iterative.rule.test.RuleTester) MockConnectorTableHandle(io.trino.connector.MockConnectorTableHandle) Symbol(io.trino.sql.planner.Symbol) Test(org.testng.annotations.Test)

Example 9 with VARCHAR

use of io.trino.spi.type.VarcharType.VARCHAR in project trino by trinodb.

the class FormatFunction method valueConverter.

private static BiFunction<ConnectorSession, Block, Object> valueConverter(FunctionDependencies functionDependencies, Type type, int position) {
    if (type.equals(UNKNOWN)) {
        return (session, block) -> null;
    }
    if (type.equals(BOOLEAN)) {
        return (session, block) -> type.getBoolean(block, position);
    }
    if (type.equals(TINYINT) || type.equals(SMALLINT) || type.equals(INTEGER) || type.equals(BIGINT)) {
        return (session, block) -> type.getLong(block, position);
    }
    if (type.equals(REAL)) {
        return (session, block) -> intBitsToFloat(toIntExact(type.getLong(block, position)));
    }
    if (type.equals(DOUBLE)) {
        return (session, block) -> type.getDouble(block, position);
    }
    if (type.equals(DATE)) {
        return (session, block) -> LocalDate.ofEpochDay(type.getLong(block, position));
    }
    if (type instanceof TimestampWithTimeZoneType) {
        return (session, block) -> toZonedDateTime(((TimestampWithTimeZoneType) type), block, position);
    }
    if (type instanceof TimestampType) {
        return (session, block) -> toLocalDateTime(((TimestampType) type), block, position);
    }
    if (type instanceof TimeType) {
        return (session, block) -> toLocalTime(type.getLong(block, position));
    }
    // TODO: support TIME WITH TIME ZONE by https://github.com/trinodb/trino/issues/191 + mapping to java.time.OffsetTime
    if (type.equals(JSON)) {
        MethodHandle handle = functionDependencies.getFunctionInvoker(QualifiedName.of("json_format"), ImmutableList.of(JSON), simpleConvention(FAIL_ON_NULL, NEVER_NULL)).getMethodHandle();
        return (session, block) -> convertToString(handle, type.getSlice(block, position));
    }
    if (isShortDecimal(type)) {
        int scale = ((DecimalType) type).getScale();
        return (session, block) -> BigDecimal.valueOf(type.getLong(block, position), scale);
    }
    if (isLongDecimal(type)) {
        int scale = ((DecimalType) type).getScale();
        return (session, block) -> new BigDecimal(((Int128) type.getObject(block, position)).toBigInteger(), scale);
    }
    if (type instanceof VarcharType) {
        return (session, block) -> type.getSlice(block, position).toStringUtf8();
    }
    if (type instanceof CharType) {
        CharType charType = (CharType) type;
        return (session, block) -> padSpaces(type.getSlice(block, position), charType).toStringUtf8();
    }
    BiFunction<ConnectorSession, Block, Object> function;
    if (type.getJavaType() == long.class) {
        function = (session, block) -> type.getLong(block, position);
    } else if (type.getJavaType() == double.class) {
        function = (session, block) -> type.getDouble(block, position);
    } else if (type.getJavaType() == boolean.class) {
        function = (session, block) -> type.getBoolean(block, position);
    } else if (type.getJavaType() == Slice.class) {
        function = (session, block) -> type.getSlice(block, position);
    } else {
        function = (session, block) -> type.getObject(block, position);
    }
    MethodHandle handle = functionDependencies.getCastInvoker(type, VARCHAR, simpleConvention(FAIL_ON_NULL, NEVER_NULL)).getMethodHandle();
    return (session, block) -> convertToString(handle, function.apply(session, block));
}
Also used : FunctionDependencies(io.trino.metadata.FunctionDependencies) SCALAR(io.trino.metadata.FunctionKind.SCALAR) FunctionDependencyDeclarationBuilder(io.trino.metadata.FunctionDependencyDeclaration.FunctionDependencyDeclarationBuilder) FAIL_ON_NULL(io.trino.spi.function.InvocationConvention.InvocationReturnConvention.FAIL_ON_NULL) BiFunction(java.util.function.BiFunction) FunctionNullability(io.trino.metadata.FunctionNullability) UNKNOWN(io.trino.type.UnknownType.UNKNOWN) InvocationConvention.simpleConvention(io.trino.spi.function.InvocationConvention.simpleConvention) Timestamps.roundDiv(io.trino.spi.type.Timestamps.roundDiv) BigDecimal(java.math.BigDecimal) TimestampWithTimeZoneType(io.trino.spi.type.TimestampWithTimeZoneType) Block(io.trino.spi.block.Block) LocalTime(java.time.LocalTime) IllegalFormatException(java.util.IllegalFormatException) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) INTEGER(io.trino.spi.type.IntegerType.INTEGER) FunctionMetadata(io.trino.metadata.FunctionMetadata) SMALLINT(io.trino.spi.type.SmallintType.SMALLINT) TypeSignature(io.trino.spi.type.TypeSignature) DateTimes.toLocalDateTime(io.trino.type.DateTimes.toLocalDateTime) FunctionDependencyDeclaration(io.trino.metadata.FunctionDependencyDeclaration) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) PICOSECONDS_PER_NANOSECOND(io.trino.type.DateTimes.PICOSECONDS_PER_NANOSECOND) TrinoException(io.trino.spi.TrinoException) String.format(java.lang.String.format) List(java.util.List) BIGINT(io.trino.spi.type.BigintType.BIGINT) INVALID_FUNCTION_ARGUMENT(io.trino.spi.StandardErrorCode.INVALID_FUNCTION_ARGUMENT) LocalDate(java.time.LocalDate) DecimalType(io.trino.spi.type.DecimalType) NEVER_NULL(io.trino.spi.function.InvocationConvention.InvocationArgumentConvention.NEVER_NULL) DATE(io.trino.spi.type.DateType.DATE) REAL(io.trino.spi.type.RealType.REAL) MethodHandle(java.lang.invoke.MethodHandle) Slice(io.airlift.slice.Slice) TimeType(io.trino.spi.type.TimeType) Decimals.isLongDecimal(io.trino.spi.type.Decimals.isLongDecimal) Type(io.trino.spi.type.Type) BOOLEAN(io.trino.spi.type.BooleanType.BOOLEAN) Float.intBitsToFloat(java.lang.Float.intBitsToFloat) DateTimes.toZonedDateTime(io.trino.type.DateTimes.toZonedDateTime) TimestampType(io.trino.spi.type.TimestampType) VarcharType(io.trino.spi.type.VarcharType) VARCHAR(io.trino.spi.type.VarcharType.VARCHAR) ImmutableList(com.google.common.collect.ImmutableList) Chars.padSpaces(io.trino.spi.type.Chars.padSpaces) Math.toIntExact(java.lang.Math.toIntExact) Signature(io.trino.metadata.Signature) Decimals.isShortDecimal(io.trino.spi.type.Decimals.isShortDecimal) Int128(io.trino.spi.type.Int128) Streams.mapWithIndex(com.google.common.collect.Streams.mapWithIndex) ConnectorSession(io.trino.spi.connector.ConnectorSession) Signature.withVariadicBound(io.trino.metadata.Signature.withVariadicBound) UsedByGeneratedCode(io.trino.annotation.UsedByGeneratedCode) SqlScalarFunction(io.trino.metadata.SqlScalarFunction) Failures.internalError(io.trino.util.Failures.internalError) QualifiedName(io.trino.sql.tree.QualifiedName) DOUBLE(io.trino.spi.type.DoubleType.DOUBLE) CharType(io.trino.spi.type.CharType) BoundSignature(io.trino.metadata.BoundSignature) TINYINT(io.trino.spi.type.TinyintType.TINYINT) JSON(io.trino.type.JsonType.JSON) Reflection.methodHandle(io.trino.util.Reflection.methodHandle) VarcharType(io.trino.spi.type.VarcharType) BigDecimal(java.math.BigDecimal) TimeType(io.trino.spi.type.TimeType) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) Slice(io.airlift.slice.Slice) TimestampWithTimeZoneType(io.trino.spi.type.TimestampWithTimeZoneType) TimestampType(io.trino.spi.type.TimestampType) DecimalType(io.trino.spi.type.DecimalType) Block(io.trino.spi.block.Block) ConnectorSession(io.trino.spi.connector.ConnectorSession) CharType(io.trino.spi.type.CharType) MethodHandle(java.lang.invoke.MethodHandle)

Example 10 with VARCHAR

use of io.trino.spi.type.VarcharType.VARCHAR in project trino by trinodb.

the class TestCreateTableTask method testCreateWithNotNullColumns.

@Test
public void testCreateWithNotNullColumns() {
    metadata.setConnectorCapabilities(NOT_NULL_COLUMN_CONSTRAINT);
    List<TableElement> inputColumns = ImmutableList.of(new ColumnDefinition(identifier("a"), toSqlType(DATE), true, emptyList(), Optional.empty()), new ColumnDefinition(identifier("b"), toSqlType(VARCHAR), false, emptyList(), Optional.empty()), new ColumnDefinition(identifier("c"), toSqlType(VARBINARY), false, emptyList(), Optional.empty()));
    CreateTable statement = new CreateTable(QualifiedName.of("test_table"), inputColumns, true, ImmutableList.of(), Optional.empty());
    CreateTableTask createTableTask = new CreateTableTask(plannerContext, new AllowAllAccessControl(), columnPropertyManager, tablePropertyManager);
    getFutureValue(createTableTask.internalExecute(statement, testSession, emptyList(), output -> {
    }));
    assertEquals(metadata.getCreateTableCallCount(), 1);
    List<ColumnMetadata> columns = metadata.getReceivedTableMetadata().get(0).getColumns();
    assertEquals(columns.size(), 3);
    assertEquals(columns.get(0).getName(), "a");
    assertEquals(columns.get(0).getType().getDisplayName().toUpperCase(ENGLISH), "DATE");
    assertTrue(columns.get(0).isNullable());
    assertEquals(columns.get(1).getName(), "b");
    assertEquals(columns.get(1).getType().getDisplayName().toUpperCase(ENGLISH), "VARCHAR");
    assertFalse(columns.get(1).isNullable());
    assertEquals(columns.get(2).getName(), "c");
    assertEquals(columns.get(2).getType().getDisplayName().toUpperCase(ENGLISH), "VARBINARY");
    assertFalse(columns.get(2).isNullable());
}
Also used : TransactionManager(io.trino.transaction.TransactionManager) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.testng.annotations.Test) TestingTableHandle(io.trino.testing.TestingMetadata.TestingTableHandle) AfterMethod(org.testng.annotations.AfterMethod) SHOW_CREATE_TABLE(io.trino.testing.TestingAccessControlManager.TestingPrivilegeType.SHOW_CREATE_TABLE) TrinoExceptionAssert.assertTrinoExceptionThrownBy(io.trino.testing.assertions.TrinoExceptionAssert.assertTrinoExceptionThrownBy) TestingConnectorTransactionHandle(io.trino.sql.planner.TestingConnectorTransactionHandle) NOT_SUPPORTED(io.trino.spi.StandardErrorCode.NOT_SUPPORTED) CatalogName(io.trino.connector.CatalogName) MockConnectorFactory(io.trino.connector.MockConnectorFactory) Map(java.util.Map) TEST_SESSION(io.trino.SessionTestUtils.TEST_SESSION) ALREADY_EXISTS(io.trino.spi.StandardErrorCode.ALREADY_EXISTS) TestingAccessControlManager(io.trino.testing.TestingAccessControlManager) Property(io.trino.sql.tree.Property) ENGLISH(java.util.Locale.ENGLISH) Assert.assertFalse(org.testng.Assert.assertFalse) Identifier(io.trino.sql.tree.Identifier) SMALLINT(io.trino.spi.type.SmallintType.SMALLINT) TableElement(io.trino.sql.tree.TableElement) ImmutableMap(com.google.common.collect.ImmutableMap) INCLUDING(io.trino.sql.tree.LikeClause.PropertiesOption.INCLUDING) Collections.emptyList(java.util.Collections.emptyList) TypeSignatureTranslator.toSqlType(io.trino.sql.analyzer.TypeSignatureTranslator.toSqlType) BeforeMethod(org.testng.annotations.BeforeMethod) Set(java.util.Set) TrinoException(io.trino.spi.TrinoException) SchemaTableName(io.trino.spi.connector.SchemaTableName) TableMetadata(io.trino.metadata.TableMetadata) List(java.util.List) TestingSession.testSessionBuilder(io.trino.testing.TestingSession.testSessionBuilder) CreateTable(io.trino.sql.tree.CreateTable) BIGINT(io.trino.spi.type.BigintType.BIGINT) Optional(java.util.Optional) ColumnPropertyManager(io.trino.metadata.ColumnPropertyManager) DATE(io.trino.spi.type.DateType.DATE) Session(io.trino.Session) PlannerContext(io.trino.sql.PlannerContext) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) AccessDeniedException(io.trino.spi.security.AccessDeniedException) SELECT_COLUMN(io.trino.testing.TestingAccessControlManager.TestingPrivilegeType.SELECT_COLUMN) AllowAllAccessControl(io.trino.security.AllowAllAccessControl) ColumnMetadata(io.trino.spi.connector.ColumnMetadata) Assert.assertEquals(org.testng.Assert.assertEquals) ConnectorTableMetadata(io.trino.spi.connector.ConnectorTableMetadata) VARCHAR(io.trino.spi.type.VarcharType.VARCHAR) ImmutableList(com.google.common.collect.ImmutableList) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) TestingPlannerContext.plannerContextBuilder(io.trino.sql.planner.TestingPlannerContext.plannerContextBuilder) LocalQueryRunner(io.trino.testing.LocalQueryRunner) Objects.requireNonNull(java.util.Objects.requireNonNull) ColumnHandle(io.trino.spi.connector.ColumnHandle) INVALID_TABLE_PROPERTY(io.trino.spi.StandardErrorCode.INVALID_TABLE_PROPERTY) VARBINARY(io.trino.spi.type.VarbinaryType.VARBINARY) EventListenerConfig(io.trino.eventlistener.EventListenerConfig) PropertyMetadata.stringProperty(io.trino.spi.session.PropertyMetadata.stringProperty) QueryUtil.identifier(io.trino.sql.QueryUtil.identifier) Sets.immutableEnumSet(com.google.common.collect.Sets.immutableEnumSet) NOT_NULL_COLUMN_CONSTRAINT(io.trino.spi.connector.ConnectorCapabilities.NOT_NULL_COLUMN_CONSTRAINT) StringLiteral(io.trino.sql.tree.StringLiteral) Collections.emptySet(java.util.Collections.emptySet) ConnectorCapabilities(io.trino.spi.connector.ConnectorCapabilities) MoreFutures.getFutureValue(io.airlift.concurrent.MoreFutures.getFutureValue) QualifiedName(io.trino.sql.tree.QualifiedName) LikeClause(io.trino.sql.tree.LikeClause) AbstractMockMetadata(io.trino.metadata.AbstractMockMetadata) TableHandle(io.trino.metadata.TableHandle) TestingAccessControlManager.privilege(io.trino.testing.TestingAccessControlManager.privilege) QualifiedObjectName(io.trino.metadata.QualifiedObjectName) EventListenerManager(io.trino.eventlistener.EventListenerManager) TablePropertyManager(io.trino.metadata.TablePropertyManager) Assert.assertTrue(org.testng.Assert.assertTrue) ColumnDefinition(io.trino.sql.tree.ColumnDefinition) ColumnMetadata(io.trino.spi.connector.ColumnMetadata) AllowAllAccessControl(io.trino.security.AllowAllAccessControl) CreateTable(io.trino.sql.tree.CreateTable) TableElement(io.trino.sql.tree.TableElement) ColumnDefinition(io.trino.sql.tree.ColumnDefinition) Test(org.testng.annotations.Test)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)37 VARCHAR (io.trino.spi.type.VarcharType.VARCHAR)37 Test (org.testng.annotations.Test)34 Optional (java.util.Optional)31 BIGINT (io.trino.spi.type.BigintType.BIGINT)30 ImmutableMap (com.google.common.collect.ImmutableMap)26 List (java.util.List)25 ColumnHandle (io.trino.spi.connector.ColumnHandle)20 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)20 Map (java.util.Map)19 TupleDomain (io.trino.spi.predicate.TupleDomain)18 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)17 Session (io.trino.Session)17 SchemaTableName (io.trino.spi.connector.SchemaTableName)16 ImmutableSet (com.google.common.collect.ImmutableSet)15 TableHandle (io.trino.metadata.TableHandle)15 Type (io.trino.spi.type.Type)15 TestingSession.testSessionBuilder (io.trino.testing.TestingSession.testSessionBuilder)15 Assert.assertTrue (org.testng.Assert.assertTrue)15 CatalogName (io.trino.connector.CatalogName)14