Search in sources :

Example 6 with TpchConnectorFactory

use of io.trino.plugin.tpch.TpchConnectorFactory in project trino by trinodb.

the class TestRowFilter method init.

@BeforeAll
public void init() {
    LocalQueryRunner runner = LocalQueryRunner.builder(SESSION).build();
    runner.createCatalog(CATALOG, new TpchConnectorFactory(1), ImmutableMap.of());
    ConnectorViewDefinition view = new ConnectorViewDefinition("SELECT nationkey, name FROM local.tiny.nation", Optional.empty(), Optional.empty(), ImmutableList.of(new ConnectorViewDefinition.ViewColumn("nationkey", BigintType.BIGINT.getTypeId()), new ConnectorViewDefinition.ViewColumn("name", VarcharType.createVarcharType(25).getTypeId())), Optional.empty(), Optional.of(VIEW_OWNER), false);
    MockConnectorFactory mock = MockConnectorFactory.builder().withGetViews((s, prefix) -> ImmutableMap.<SchemaTableName, ConnectorViewDefinition>builder().put(new SchemaTableName("default", "nation_view"), view).buildOrThrow()).withGetColumns(schemaTableName -> {
        if (schemaTableName.equals(new SchemaTableName("tiny", "nation"))) {
            return TPCH_NATION_SCHEMA;
        }
        if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_hidden_column"))) {
            return TPCH_NATION_WITH_HIDDEN_COLUMN;
        }
        if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_optional_column"))) {
            return TPCH_NATION_WITH_OPTIONAL_COLUMN;
        }
        throw new UnsupportedOperationException();
    }).withData(schemaTableName -> {
        if (schemaTableName.equals(new SchemaTableName("tiny", "nation"))) {
            return TPCH_NATION_DATA;
        }
        if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_hidden_column"))) {
            return TPCH_WITH_HIDDEN_COLUMN_DATA;
        }
        if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_optional_column"))) {
            return TPCH_NATION_DATA;
        }
        throw new UnsupportedOperationException();
    }).build();
    runner.createCatalog(MOCK_CATALOG, mock, ImmutableMap.of());
    MockConnectorFactory mockMissingColumns = MockConnectorFactory.builder().withName("mockmissingcolumns").withGetViews((s, prefix) -> ImmutableMap.<SchemaTableName, ConnectorViewDefinition>builder().put(new SchemaTableName("default", "nation_view"), view).buildOrThrow()).withGetColumns(schemaTableName -> {
        if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_optional_column"))) {
            return TPCH_NATION_WITH_OPTIONAL_COLUMN;
        }
        throw new UnsupportedOperationException();
    }).withData(schemaTableName -> {
        if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_optional_column"))) {
            return TPCH_NATION_DATA;
        }
        throw new UnsupportedOperationException();
    }).withAllowMissingColumnsOnInsert(true).build();
    runner.createCatalog(MOCK_CATALOG_MISSING_COLUMNS, mockMissingColumns, ImmutableMap.of());
    assertions = new QueryAssertions(runner);
    accessControl = assertions.getQueryRunner().getAccessControl();
}
Also used : TPCH_NATION_WITH_OPTIONAL_COLUMN(io.trino.connector.MockConnectorEntities.TPCH_NATION_WITH_OPTIONAL_COLUMN) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SAME_THREAD(org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD) AfterAll(org.junit.jupiter.api.AfterAll) BigintType(io.trino.spi.type.BigintType) VarcharType(io.trino.spi.type.VarcharType) TestInstance(org.junit.jupiter.api.TestInstance) ImmutableList(com.google.common.collect.ImmutableList) MockConnectorFactory(io.trino.connector.MockConnectorFactory) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) BeforeAll(org.junit.jupiter.api.BeforeAll) TpchConnectorFactory(io.trino.plugin.tpch.TpchConnectorFactory) Identity(io.trino.spi.security.Identity) LocalQueryRunner(io.trino.testing.LocalQueryRunner) TestingAccessControlManager(io.trino.testing.TestingAccessControlManager) ConnectorViewDefinition(io.trino.spi.connector.ConnectorViewDefinition) TINY_SCHEMA_NAME(io.trino.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME) ImmutableMap(com.google.common.collect.ImmutableMap) ViewExpression(io.trino.spi.security.ViewExpression) TPCH_NATION_DATA(io.trino.connector.MockConnectorEntities.TPCH_NATION_DATA) PER_CLASS(org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS) TrinoException(io.trino.spi.TrinoException) TPCH_NATION_SCHEMA(io.trino.connector.MockConnectorEntities.TPCH_NATION_SCHEMA) TPCH_WITH_HIDDEN_COLUMN_DATA(io.trino.connector.MockConnectorEntities.TPCH_WITH_HIDDEN_COLUMN_DATA) SchemaTableName(io.trino.spi.connector.SchemaTableName) Test(org.junit.jupiter.api.Test) TestingSession.testSessionBuilder(io.trino.testing.TestingSession.testSessionBuilder) QualifiedObjectName(io.trino.metadata.QualifiedObjectName) Optional(java.util.Optional) Execution(org.junit.jupiter.api.parallel.Execution) TPCH_NATION_WITH_HIDDEN_COLUMN(io.trino.connector.MockConnectorEntities.TPCH_NATION_WITH_HIDDEN_COLUMN) Session(io.trino.Session) TpchConnectorFactory(io.trino.plugin.tpch.TpchConnectorFactory) MockConnectorFactory(io.trino.connector.MockConnectorFactory) SchemaTableName(io.trino.spi.connector.SchemaTableName) LocalQueryRunner(io.trino.testing.LocalQueryRunner) ConnectorViewDefinition(io.trino.spi.connector.ConnectorViewDefinition) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 7 with TpchConnectorFactory

use of io.trino.plugin.tpch.TpchConnectorFactory in project trino by trinodb.

the class TestSubqueries method init.

@BeforeAll
public void init() {
    Session session = testSessionBuilder().setCatalog(CATALOG).setSchema(TINY_SCHEMA_NAME).build();
    LocalQueryRunner runner = LocalQueryRunner.builder(session).build();
    runner.createCatalog(CATALOG, new TpchConnectorFactory(1), ImmutableMap.of());
    assertions = new QueryAssertions(runner);
}
Also used : TpchConnectorFactory(io.trino.plugin.tpch.TpchConnectorFactory) LocalQueryRunner(io.trino.testing.LocalQueryRunner) Session(io.trino.Session) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 8 with TpchConnectorFactory

use of io.trino.plugin.tpch.TpchConnectorFactory in project trino by trinodb.

the class TestHiddenColumns method setUp.

@BeforeClass
public void setUp() {
    runner = LocalQueryRunner.create(TEST_SESSION);
    runner.createCatalog(TEST_SESSION.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
}
Also used : TpchConnectorFactory(io.trino.plugin.tpch.TpchConnectorFactory) BeforeClass(org.testng.annotations.BeforeClass)

Example 9 with TpchConnectorFactory

use of io.trino.plugin.tpch.TpchConnectorFactory in project trino by trinodb.

the class RuleTester method defaultRuleTester.

public static RuleTester defaultRuleTester(List<Plugin> plugins, Map<String, String> sessionProperties, Optional<Integer> nodeCountForStats) {
    Session.SessionBuilder sessionBuilder = testSessionBuilder().setCatalog(CATALOG_ID).setSchema("tiny").setSystemProperty("task_concurrency", // these tests don't handle exchanges from local parallel
    "1");
    for (Map.Entry<String, String> entry : sessionProperties.entrySet()) {
        sessionBuilder.setSystemProperty(entry.getKey(), entry.getValue());
    }
    Session session = sessionBuilder.build();
    LocalQueryRunner queryRunner = nodeCountForStats.map(nodeCount -> LocalQueryRunner.builder(session).withNodeCountForStats(nodeCount).build()).orElseGet(() -> LocalQueryRunner.create(session));
    queryRunner.createCatalog(session.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
    plugins.forEach(queryRunner::installPlugin);
    return new RuleTester(queryRunner);
}
Also used : TypeAnalyzer.createTestingTypeAnalyzer(io.trino.sql.planner.TypeAnalyzer.createTestingTypeAnalyzer) ImmutableMap(com.google.common.collect.ImmutableMap) TransactionManager(io.trino.transaction.TransactionManager) PageSourceManager(io.trino.split.PageSourceManager) SplitManager(io.trino.split.SplitManager) FunctionManager(io.trino.metadata.FunctionManager) Plugin(io.trino.spi.Plugin) CatalogName(io.trino.connector.CatalogName) List(java.util.List) TestingSession.testSessionBuilder(io.trino.testing.TestingSession.testSessionBuilder) TypeAnalyzer(io.trino.sql.planner.TypeAnalyzer) ImmutableList(com.google.common.collect.ImmutableList) AccessControl(io.trino.security.AccessControl) TpchConnectorFactory(io.trino.plugin.tpch.TpchConnectorFactory) LocalQueryRunner(io.trino.testing.LocalQueryRunner) Closeable(java.io.Closeable) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) Metadata(io.trino.metadata.Metadata) Optional(java.util.Optional) Rule(io.trino.sql.planner.iterative.Rule) Session(io.trino.Session) PlannerContext(io.trino.sql.PlannerContext) TpchConnectorFactory(io.trino.plugin.tpch.TpchConnectorFactory) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) LocalQueryRunner(io.trino.testing.LocalQueryRunner) Session(io.trino.Session)

Example 10 with TpchConnectorFactory

use of io.trino.plugin.tpch.TpchConnectorFactory in project trino by trinodb.

the class BenchmarkQueryRunner method createLocalQueryRunner.

public static LocalQueryRunner createLocalQueryRunner(Map<String, String> extraSessionProperties) {
    SessionBuilder sessionBuilder = testSessionBuilder().setCatalog("tpch").setSchema(TINY_SCHEMA_NAME);
    extraSessionProperties.forEach(sessionBuilder::setSystemProperty);
    Session session = sessionBuilder.build();
    LocalQueryRunner localQueryRunner = LocalQueryRunner.create(session);
    // add tpch
    localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of());
    return localQueryRunner;
}
Also used : TpchConnectorFactory(io.trino.plugin.tpch.TpchConnectorFactory) TestingSession.testSessionBuilder(io.trino.testing.TestingSession.testSessionBuilder) SessionBuilder(io.trino.Session.SessionBuilder) LocalQueryRunner(io.trino.testing.LocalQueryRunner) Session(io.trino.Session)

Aggregations

TpchConnectorFactory (io.trino.plugin.tpch.TpchConnectorFactory)31 LocalQueryRunner (io.trino.testing.LocalQueryRunner)25 Session (io.trino.Session)17 BeforeClass (org.testng.annotations.BeforeClass)7 TestingSession.testSessionBuilder (io.trino.testing.TestingSession.testSessionBuilder)5 BeforeAll (org.junit.jupiter.api.BeforeAll)5 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 FeaturesConfig (io.trino.FeaturesConfig)3 ConnectorMetadata (io.trino.spi.connector.ConnectorMetadata)3 Optional (java.util.Optional)3 Test (org.testng.annotations.Test)3 SessionBuilder (io.trino.Session.SessionBuilder)2 TPCH_NATION_WITH_HIDDEN_COLUMN (io.trino.connector.MockConnectorEntities.TPCH_NATION_WITH_HIDDEN_COLUMN)2 TPCH_WITH_HIDDEN_COLUMN_DATA (io.trino.connector.MockConnectorEntities.TPCH_WITH_HIDDEN_COLUMN_DATA)2 MockConnectorFactory (io.trino.connector.MockConnectorFactory)2 QualifiedObjectName (io.trino.metadata.QualifiedObjectName)2 MemoryConnectorFactory (io.trino.plugin.memory.MemoryConnectorFactory)2 TINY_SCHEMA_NAME (io.trino.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME)2 ConnectorViewDefinition (io.trino.spi.connector.ConnectorViewDefinition)2