Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
Copy link
Copy Markdown
Member

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?

* 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
Expand Up @@ -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;
Expand All @@ -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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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
Expand All @@ -44,4 +44,21 @@ public void testShowSchemas()
.row("sf1");
assertContains(actualSchemas, resultBuilder.build());
}

@Test
public void testCreateArrayTable()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.