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

Update Trino version to 405 #90

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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);
}
}
}