Skip to content

Commit

Permalink
Add ScyllaDB connector
Browse files Browse the repository at this point in the history
Set minimum required version as 3.0.0 because
ScyllaDB version 2.x can't detect partition
correctly and it leads to query failure.
  • Loading branch information
ebyhr committed May 28, 2022
1 parent e9da9fe commit bf0365f
Show file tree
Hide file tree
Showing 27 changed files with 606 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ jobs:
!:trino-raptor-legacy,
!:trino-accumulo,
!:trino-cassandra,
!:trino-scylla,
!:trino-clickhouse,
!:trino-delta-lake,
!:trino-hive,
Expand Down Expand Up @@ -386,6 +387,7 @@ jobs:
- { modules: plugin/trino-raptor-legacy }
- { modules: plugin/trino-accumulo }
- { modules: plugin/trino-cassandra }
- { modules: plugin/trino-scylla }
- { modules: plugin/trino-clickhouse }
- { modules: plugin/trino-delta-lake }
- { modules: plugin/trino-delta-lake, profile: test-failure-recovery }
Expand Down
6 changes: 6 additions & 0 deletions core/trino-server/src/main/provisio/trino.xml
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,10 @@
<unpack />
</artifact>
</artifactSet>

<artifactSet to="plugin/scylla">
<artifact id="${project.groupId}:trino-scylla:zip:${project.version}">
<unpack />
</artifact>
</artifactSet>
</runtime>
1 change: 1 addition & 0 deletions docs/src/main/sphinx/connector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ from different data sources.
Prometheus <connector/prometheus>
Redis <connector/redis>
Redshift <connector/redshift>
Scylla <connector/scylla>
SingleStore (MemSQL) <connector/memsql>
SQL Server <connector/sqlserver>
System <connector/system>
Expand Down
38 changes: 38 additions & 0 deletions docs/src/main/sphinx/connector/scylla.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
================
Scylla connector
================

The Scylla connector allows querying data stored in
`Scylla <https://www.scylladb.com//>`_.

Requirements
------------

To connect to Scylla, you need:

* Scylla version 3.0.0 or higher.
* Network access from the Trino coordinator and workers to Scylla.
Port 9042 is the default port.

Configuration
-------------

To configure the Scylla connector, create a catalog properties file
``etc/catalog/scylla.properties`` with the following contents,
replacing ``host1,host2`` with a comma-separated list of the Scylla
nodes, used to discovery the cluster topology:

.. code-block:: text
connector.name=scylla
cassandra.contact-points=host1,host2
You also need to set ``cassandra.native-protocol-port``, if your
Scylla nodes are not using the default port 9042.

Compatibility with Cassandra connector
--------------------------------------

The Scylla connector is very similar to the Cassandra connector with the
only difference being the underlying driver.
See :doc:`Cassandra connector <cassandra>` for more details.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ protected QueryRunner createQueryRunner()
server = closeAfterClass(new TestingCassandraServer());
session = server.getSession();
createTestTables(session, KEYSPACE, Timestamp.from(TIMESTAMP_VALUE.toInstant()));
return createCassandraQueryRunner(server, ImmutableMap.of(), REQUIRED_TPCH_TABLES);
return createCassandraQueryRunner(server, ImmutableMap.of(), ImmutableMap.of(), REQUIRED_TPCH_TABLES);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class TestCassandraProtocolVersionV3ConnectorSmokeTest
protected QueryRunner createQueryRunner()
throws Exception
{
CassandraServer server = closeAfterClass(new CassandraServer());
CassandraServer server = closeAfterClass(new TestingCassandraServer());
CassandraSession session = server.getSession();
createTestTables(session, KEYSPACE, Timestamp.from(TIMESTAMP_VALUE.toInstant()));
return createCassandraQueryRunner(server, ImmutableMap.of(), ImmutableMap.of("cassandra.protocol-version", "V3"), REQUIRED_TPCH_TABLES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private static void checkIsDoubled(ZoneId zone, LocalDateTime dateTime)
protected QueryRunner createQueryRunner()
throws Exception
{
server = closeAfterClass(new CassandraServer());
server = closeAfterClass(new TestingCassandraServer());
session = server.getSession();
return createCassandraQueryRunner(
server,
Expand Down
203 changes: 203 additions & 0 deletions plugin/trino-scylla/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.trino</groupId>
<artifactId>trino-root</artifactId>
<version>383-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>trino-scylla</artifactId>
<description>Trino - Scylla Connector</description>
<packaging>trino-plugin</packaging>

<properties>
<air.main.basedir>${project.parent.basedir}</air.main.basedir>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-analysis</artifactId>
<version>9.2</version>
</dependency>

<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-tree</artifactId>
<version>9.2</version>
</dependency>

<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<version>9.2</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-cassandra</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-core</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- used by tests but also needed transitively -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>json</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>log</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>log-manager</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>units</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>com.scylladb</groupId>
<artifactId>java-driver-core</artifactId>
<version>4.13.0.0</version>
<scope>runtime</scope>
</dependency>

<!-- Trino SPI -->
<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-spi</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>slice</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openjdk.jol</groupId>
<artifactId>jol-core</artifactId>
<scope>provided</scope>
</dependency>

<!-- for testing -->
<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-cassandra</artifactId>
<type>test-jar</type>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-main</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-main</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-testing</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-tpch</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.trino.tpch</groupId>
<artifactId>tpch</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>testing</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.basepom.maven</groupId>
<artifactId>duplicate-finder-maven-plugin</artifactId>
<configuration>
<ignoredDependencies>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-core</artifactId>
</dependency>
</ignoredDependencies>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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.scylla;

import io.trino.plugin.cassandra.CassandraConnectorFactory;

public class ScyllaConnectorFactory
extends CassandraConnectorFactory
{
@Override
public String getName()
{
return "scylla";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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.scylla;

import com.google.common.collect.ImmutableList;
import io.trino.spi.Plugin;
import io.trino.spi.connector.ConnectorFactory;

public class ScyllaPlugin
implements Plugin
{
@Override
public Iterable<ConnectorFactory> getConnectorFactories()
{
return ImmutableList.of(new ScyllaConnectorFactory());
}
}
Loading

0 comments on commit bf0365f

Please sign in to comment.