18
18
import io .trino .plugin .jdbc .ColumnMapping ;
19
19
import io .trino .plugin .jdbc .ConnectionFactory ;
20
20
import io .trino .plugin .jdbc .JdbcSplit ;
21
+ import io .trino .plugin .jdbc .JdbcTableHandle ;
21
22
import io .trino .plugin .jdbc .JdbcTypeHandle ;
22
23
import io .trino .plugin .jdbc .LongReadFunction ;
23
24
import io .trino .plugin .jdbc .ObjectReadFunction ;
24
25
import io .trino .plugin .jdbc .ObjectWriteFunction ;
25
26
import io .trino .plugin .jdbc .QueryBuilder ;
26
27
import io .trino .plugin .jdbc .WriteMapping ;
28
+ import io .trino .plugin .jdbc .logging .RemoteQueryModifier ;
27
29
import io .trino .plugin .jdbc .mapping .IdentifierMapping ;
28
30
import io .trino .spi .TrinoException ;
29
31
import io .trino .spi .connector .ConnectorSession ;
34
36
import io .trino .spi .type .LongTimestamp ;
35
37
import io .trino .spi .type .TimestampType ;
36
38
import io .trino .spi .type .Type ;
37
- import io .trino .spi .type .TypeManager ;
38
39
import io .trino .spi .type .VarcharType ;
39
40
40
41
import javax .inject .Inject ;
@@ -116,22 +117,22 @@ public DB2Client(
116
117
DB2Config db2config ,
117
118
ConnectionFactory connectionFactory ,
118
119
QueryBuilder queryBuilder ,
119
- TypeManager typeManager ,
120
- IdentifierMapping identifierMapping )
120
+ IdentifierMapping identifierMapping ,
121
+ RemoteQueryModifier remoteQueryModifier )
121
122
throws SQLException
122
123
{
123
- super (config , "\" " , connectionFactory , queryBuilder , identifierMapping );
124
+ super (config , "\" " , connectionFactory , queryBuilder , identifierMapping , remoteQueryModifier );
124
125
this .varcharMaxLength = db2config .getVarcharMaxLength ();
125
126
126
127
// http://stackoverflow.com/questions/16910791/getting-error-code-4220-with-null-sql-state
127
128
System .setProperty ("db2.jcc.charsetDecoderEncoder" , "3" );
128
129
}
129
130
130
131
@ Override
131
- public Connection getConnection (ConnectorSession session , JdbcSplit split )
132
+ public Connection getConnection (ConnectorSession session , JdbcSplit split , JdbcTableHandle jdbcTableHandle )
132
133
throws SQLException
133
134
{
134
- Connection connection = super .getConnection (session , split );
135
+ Connection connection = super .getConnection (session , split , jdbcTableHandle );
135
136
try {
136
137
// TRANSACTION_READ_UNCOMMITTED = Uncommitted read
137
138
// http://www.ibm.com/developerworks/data/library/techarticle/dm-0509schuetz/
@@ -309,10 +310,10 @@ else if (varcharType.getBoundedLength() < this.varcharMaxLength) {
309
310
return WriteMapping .longMapping (format ("TIMESTAMP(%s)" , timestampType .getPrecision ()), timestampWriteFunction (timestampType ));
310
311
}
311
312
312
- return this .legacyToWriteMapping (session , type );
313
+ return this .legacyToWriteMapping (type );
313
314
}
314
315
315
- protected WriteMapping legacyToWriteMapping (ConnectorSession session , Type type )
316
+ protected WriteMapping legacyToWriteMapping (Type type )
316
317
{
317
318
if (type instanceof VarcharType ) {
318
319
VarcharType varcharType = (VarcharType ) type ;
@@ -380,15 +381,15 @@ protected void renameTable(ConnectorSession session, String catalogName, String
380
381
"RENAME TABLE %s TO %s" ,
381
382
quoted (catalogName , schemaName , tableName ),
382
383
quoted (newTableName ));
383
- execute (connection , sql );
384
+ execute (session , connection , sql );
384
385
}
385
386
catch (SQLException e ) {
386
387
throw new TrinoException (JDBC_ERROR , e );
387
388
}
388
389
}
389
390
390
391
@ Override
391
- protected void copyTableSchema (Connection connection , String catalogName , String schemaName , String tableName , String newTableName , List <String > columnNames )
392
+ protected void copyTableSchema (ConnectorSession session , Connection connection , String catalogName , String schemaName , String tableName , String newTableName , List <String > columnNames )
392
393
{
393
394
String sql = format (
394
395
"CREATE TABLE %s AS (SELECT %s FROM %s) WITH NO DATA" ,
@@ -397,6 +398,12 @@ protected void copyTableSchema(Connection connection, String catalogName, String
397
398
.map (this ::quoted )
398
399
.collect (joining (", " )),
399
400
quoted (catalogName , schemaName , tableName ));
400
- execute (connection , sql );
401
+
402
+ try {
403
+ execute (session , connection , sql );
404
+ }
405
+ catch (SQLException e ) {
406
+ throw new TrinoException (JDBC_ERROR , e );
407
+ }
401
408
}
402
409
}
0 commit comments