-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Migrate Thrift connector tests to use BaseConnectorTest #7117 #7975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.trino.plugin.thrift; | ||
|
|
||
| import io.airlift.bootstrap.LifeCycleManager; | ||
| import io.trino.spi.connector.Connector; | ||
| import io.trino.spi.connector.ConnectorIndexProvider; | ||
| import io.trino.spi.connector.ConnectorMetadata; | ||
| import io.trino.spi.connector.ConnectorPageSourceProvider; | ||
| import io.trino.spi.connector.ConnectorSplitManager; | ||
| import io.trino.spi.connector.ConnectorTransactionHandle; | ||
| import io.trino.spi.session.PropertyMetadata; | ||
| import io.trino.spi.transaction.IsolationLevel; | ||
|
|
||
| import javax.inject.Inject; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import static java.util.Objects.requireNonNull; | ||
|
|
||
| public class MyThriftConnector | ||
| implements Connector | ||
| { | ||
| private final LifeCycleManager lifeCycleManager; | ||
| private final ThriftMetadata metadata; | ||
| private final ThriftSplitManager splitManager; | ||
| private final ThriftPageSourceProvider pageSourceProvider; | ||
| private final ThriftSessionProperties sessionProperties; | ||
| private final ThriftIndexProvider indexProvider; | ||
|
|
||
| @Inject | ||
| public MyThriftConnector( | ||
| LifeCycleManager lifeCycleManager, | ||
| ThriftMetadata metadata, | ||
| ThriftSplitManager splitManager, | ||
| ThriftPageSourceProvider pageSourceProvider, | ||
| ThriftSessionProperties sessionProperties, | ||
| ThriftIndexProvider indexProvider) | ||
| { | ||
| this.lifeCycleManager = requireNonNull(lifeCycleManager, "lifeCycleManager is null"); | ||
| this.metadata = requireNonNull(metadata, "metadata is null"); | ||
| this.splitManager = requireNonNull(splitManager, "splitManager is null"); | ||
| this.pageSourceProvider = requireNonNull(pageSourceProvider, "pageSourceProvider is null"); | ||
| this.sessionProperties = requireNonNull(sessionProperties, "sessionProperties is null"); | ||
| this.indexProvider = requireNonNull(indexProvider, "indexProvider is null"); | ||
| } | ||
|
|
||
| @Override | ||
| public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) | ||
| { | ||
| return ThriftTransactionHandle.INSTANCE; | ||
| } | ||
|
|
||
| @Override | ||
| public ConnectorMetadata getMetadata(ConnectorTransactionHandle transactionHandle) | ||
| { | ||
| return metadata; | ||
| } | ||
|
|
||
| @Override | ||
| public ConnectorSplitManager getSplitManager() | ||
| { | ||
| return splitManager; | ||
| } | ||
|
|
||
| @Override | ||
| public ConnectorPageSourceProvider getPageSourceProvider() | ||
| { | ||
| return pageSourceProvider; | ||
| } | ||
|
|
||
| @Override | ||
| public List<PropertyMetadata<?>> getSessionProperties() | ||
| { | ||
| return sessionProperties.getSessionProperties(); | ||
| } | ||
|
|
||
| @Override | ||
| public ConnectorIndexProvider getIndexProvider() | ||
| { | ||
| return indexProvider; | ||
| } | ||
|
|
||
| @Override | ||
| public final void shutdown() | ||
| { | ||
| lifeCycleManager.stop(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| package io.trino.plugin.thrift.integration; | ||
|
|
||
| import com.google.common.collect.ImmutableMap; | ||
| import io.trino.testing.AbstractTestIntegrationSmokeTest; | ||
| import io.trino.testing.BaseConnectorTest; | ||
| import io.trino.testing.MaterializedResult; | ||
| import io.trino.testing.QueryRunner; | ||
| import org.testng.annotations.Test; | ||
|
|
@@ -23,15 +23,15 @@ | |
| import static io.trino.spi.type.VarcharType.VARCHAR; | ||
| import static io.trino.testing.QueryAssertions.assertContains; | ||
|
|
||
| public class TestThriftIntegrationSmokeTest | ||
| public class TestThriftConnectorTest | ||
| // TODO extend BaseConnectorTest | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the TODO since it seems adressed now. |
||
| extends AbstractTestIntegrationSmokeTest | ||
| extends BaseConnectorTest | ||
| { | ||
| @Override | ||
| protected QueryRunner createQueryRunner() | ||
| throws Exception | ||
| { | ||
| return createThriftQueryRunner(2, false, ImmutableMap.of()); | ||
| return createThriftQueryRunner(3, false, ImmutableMap.of()); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -44,4 +44,21 @@ public void testShowSchemas() | |
| .row("sf1"); | ||
| assertContains(actualSchemas, resultBuilder.build()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testCreateArrayTable() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add these in a new commit since they are new tests not part of either the existing smoke test or the distributed queries test. |
||
| { | ||
| assertUpdate("CREATE TABLE array_test AS SELECT ARRAY [1, 2, 3] AS c", 1); | ||
| assertQuery("SELECT cardinality(c) FROM array_test", "SELECT 3"); | ||
| assertUpdate("DROP TABLE array_test"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testMapTable() | ||
| { | ||
| assertUpdate("CREATE TABLE map_test AS SELECT MAP(ARRAY [1, 2, 3], ARRAY ['hi', 'bye', NULL]) AS c", 1); | ||
| assertQuery("SELECT c[1] FROM map_test", "SELECT 'hi'"); | ||
| assertQuery("SELECT c[3] FROM map_test", "SELECT NULL"); | ||
| assertUpdate("DROP TABLE map_test"); | ||
| } | ||
| } | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this class required?