Skip to content

Commit

Permalink
Merge pull request trinodb#6 from academy-codex/mr_trino_sybase_conne…
Browse files Browse the repository at this point in the history
…ctor_fixes

Mr trino sybase connector fixes
  • Loading branch information
academy-codex authored Jul 17, 2021
2 parents 55ff4de + 618cce6 commit 3170f9a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ public class SybaseClient

private static final Joiner DOT_JOINER = Joiner.on(".");

@Override
public void createSchema(ConnectorSession session, String schemaName)
{
// TODO: Add try-catch for error message parsing (test cases patch)
super.createSchema(session, schemaName);
}

@Inject
public SybaseClient(BaseJdbcConfig config, ConnectionFactory connectionFactory, IdentifierMapping identifierMapping)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
*/
package io.trino.plugin.sybase;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.airlift.log.Logger;
import io.airlift.log.Logging;
import io.trino.Session;
import io.trino.plugin.tpch.TpchPlugin;
import io.trino.testing.DistributedQueryRunner;
import io.trino.testing.QueryRunner;
import io.trino.tpch.TpchTable;

import java.util.HashMap;
Expand All @@ -35,16 +35,15 @@ private SybaseQueryRunner() {}

private static final String TPCH_SCHEMA = "tpch";

public static QueryRunner createSybaseQueryRunner(TestingSybaseServer server, TpchTable<?>... tables)
public static DistributedQueryRunner createSybaseQueryRunner(TestingSybaseServer server,
Map<String, String> extraProperties,
Map<String, String> connectorProperties,
Iterable<TpchTable<?>> tables)
throws Exception
{
return createSybaseQueryRunner(server, ImmutableMap.of(), ImmutableList.copyOf(tables));
}

public static QueryRunner createSybaseQueryRunner(TestingSybaseServer server, Map<String, String> connectorProperties, Iterable<TpchTable<?>> tables)
throws Exception
{
DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(createSession()).build();
DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(createSession())
.setExtraProperties(extraProperties)
.build();
try {
queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog("tpch", "tpch");
Expand Down Expand Up @@ -75,4 +74,20 @@ private static Session createSession()
.setSchema("dbo")
.build();
}

public static void main(String[] args)
throws Exception
{
Logging.initialize();

DistributedQueryRunner queryRunner = createSybaseQueryRunner(
new TestingSybaseServer(),
ImmutableMap.of("http-server.http.port", "8080"),
ImmutableMap.of(),
TpchTable.getTables());

Logger log = Logger.get(SybaseQueryRunner.class);
log.info("======== SERVER STARTED ========");
log.info("\n====\n%s\n====", queryRunner.getCoordinator().getBaseUrl());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected QueryRunner createQueryRunner()
throws Exception
{
sybaseServer = new TestingSybaseServer();
return createSybaseQueryRunner(sybaseServer, ImmutableMap.of(), REQUIRED_TPCH_TABLES);
return createSybaseQueryRunner(sybaseServer, ImmutableMap.of(), ImmutableMap.of(), REQUIRED_TPCH_TABLES);
}

@AfterClass(alwaysRun = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public void testCreateConnector()
{
Plugin plugin = new SybasePlugin();
ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
factory.create("test", ImmutableMap.of("connection-url", "jdbc:mariadb://test"), new TestingConnectorContext()).shutdown();
factory.create("test", ImmutableMap.of("connection-url", "jdbc:jtds:sybase://testdb"), new TestingConnectorContext()).shutdown();
}
}

This file was deleted.

1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
<module>plugin/trino-resource-group-managers</module>
<module>plugin/trino-session-property-managers</module>
<module>plugin/trino-sqlserver</module>
<module>plugin/trino-sybase</module>
<module>plugin/trino-teradata-functions</module>
<module>plugin/trino-thrift</module>
<module>plugin/trino-thrift-api</module>
Expand Down

0 comments on commit 3170f9a

Please sign in to comment.