Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Commit

Permalink
Update Trino version to 405
Browse files Browse the repository at this point in the history
- Remove unused variables
- Apply changed public or protected interfaces
- Use execute with already created connection

Signed-off-by: leeyh0216 <[email protected]>
  • Loading branch information
leeyh0216 committed Jan 6, 2023
1 parent 2fc81bb commit 53d432a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.trino</groupId>
<artifactId>trino-root</artifactId>
<version>396</version>
<version>405</version>
</parent>

<artifactId>trino-db2</artifactId>
Expand Down
29 changes: 18 additions & 11 deletions src/main/java/io/trino/plugin/db2/DB2Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
import io.trino.plugin.jdbc.ColumnMapping;
import io.trino.plugin.jdbc.ConnectionFactory;
import io.trino.plugin.jdbc.JdbcSplit;
import io.trino.plugin.jdbc.JdbcTableHandle;
import io.trino.plugin.jdbc.JdbcTypeHandle;
import io.trino.plugin.jdbc.LongReadFunction;
import io.trino.plugin.jdbc.ObjectReadFunction;
import io.trino.plugin.jdbc.ObjectWriteFunction;
import io.trino.plugin.jdbc.QueryBuilder;
import io.trino.plugin.jdbc.WriteMapping;
import io.trino.plugin.jdbc.logging.RemoteQueryModifier;
import io.trino.plugin.jdbc.mapping.IdentifierMapping;
import io.trino.spi.TrinoException;
import io.trino.spi.connector.ConnectorSession;
Expand All @@ -34,7 +36,6 @@
import io.trino.spi.type.LongTimestamp;
import io.trino.spi.type.TimestampType;
import io.trino.spi.type.Type;
import io.trino.spi.type.TypeManager;
import io.trino.spi.type.VarcharType;

import javax.inject.Inject;
Expand Down Expand Up @@ -116,22 +117,22 @@ public DB2Client(
DB2Config db2config,
ConnectionFactory connectionFactory,
QueryBuilder queryBuilder,
TypeManager typeManager,
IdentifierMapping identifierMapping)
IdentifierMapping identifierMapping,
RemoteQueryModifier remoteQueryModifier)
throws SQLException
{
super(config, "\"", connectionFactory, queryBuilder, identifierMapping);
super(config, "\"", connectionFactory, queryBuilder, identifierMapping, remoteQueryModifier);
this.varcharMaxLength = db2config.getVarcharMaxLength();

// http://stackoverflow.com/questions/16910791/getting-error-code-4220-with-null-sql-state
System.setProperty("db2.jcc.charsetDecoderEncoder", "3");
}

@Override
public Connection getConnection(ConnectorSession session, JdbcSplit split)
public Connection getConnection(ConnectorSession session, JdbcSplit split, JdbcTableHandle jdbcTableHandle)
throws SQLException
{
Connection connection = super.getConnection(session, split);
Connection connection = super.getConnection(session, split, jdbcTableHandle);
try {
// TRANSACTION_READ_UNCOMMITTED = Uncommitted read
// http://www.ibm.com/developerworks/data/library/techarticle/dm-0509schuetz/
Expand Down Expand Up @@ -309,10 +310,10 @@ else if (varcharType.getBoundedLength() < this.varcharMaxLength) {
return WriteMapping.longMapping(format("TIMESTAMP(%s)", timestampType.getPrecision()), timestampWriteFunction(timestampType));
}

return this.legacyToWriteMapping(session, type);
return this.legacyToWriteMapping(type);
}

protected WriteMapping legacyToWriteMapping(ConnectorSession session, Type type)
protected WriteMapping legacyToWriteMapping(Type type)
{
if (type instanceof VarcharType) {
VarcharType varcharType = (VarcharType) type;
Expand Down Expand Up @@ -380,15 +381,15 @@ protected void renameTable(ConnectorSession session, String catalogName, String
"RENAME TABLE %s TO %s",
quoted(catalogName, schemaName, tableName),
quoted(newTableName));
execute(connection, sql);
execute(session, connection, sql);
}
catch (SQLException e) {
throw new TrinoException(JDBC_ERROR, e);
}
}

@Override
protected void copyTableSchema(Connection connection, String catalogName, String schemaName, String tableName, String newTableName, List<String> columnNames)
protected void copyTableSchema(ConnectorSession session, Connection connection, String catalogName, String schemaName, String tableName, String newTableName, List<String> columnNames)
{
String sql = format(
"CREATE TABLE %s AS (SELECT %s FROM %s) WITH NO DATA",
Expand All @@ -397,6 +398,12 @@ protected void copyTableSchema(Connection connection, String catalogName, String
.map(this::quoted)
.collect(joining(", ")),
quoted(catalogName, schemaName, tableName));
execute(connection, sql);

try {
execute(session, connection, sql);
}
catch (SQLException e) {
throw new TrinoException(JDBC_ERROR, e);
}
}
}

0 comments on commit 53d432a

Please sign in to comment.