diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/BaseJdbcClient.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/BaseJdbcClient.java index 90197c6fb62f..699c84ecaa44 100644 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/BaseJdbcClient.java +++ b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/BaseJdbcClient.java @@ -931,9 +931,7 @@ protected JdbcOutputTableHandle createTable( } return new JdbcOutputTableHandle( - catalog, - remoteSchema, - remoteTable, + new RemoteTableName(Optional.ofNullable(catalog), Optional.ofNullable(remoteSchema), remoteTable), columnNames.build(), columnTypes.build(), Optional.empty(), @@ -1015,9 +1013,7 @@ protected JdbcOutputTableHandle beginInsertTable( if (isNonTransactionalInsert(session)) { return new JdbcOutputTableHandle( - catalog, - remoteSchema, - remoteTable, + new RemoteTableName(Optional.ofNullable(catalog), Optional.ofNullable(remoteSchema), remoteTable), columnNames.build(), columnTypes.build(), Optional.of(jdbcColumnTypes.build()), @@ -1039,9 +1035,7 @@ protected JdbcOutputTableHandle beginInsertTable( } return new JdbcOutputTableHandle( - catalog, - remoteSchema, - remoteTable, + new RemoteTableName(Optional.ofNullable(catalog), Optional.ofNullable(remoteSchema), remoteTable), columnNames.build(), columnTypes.build(), Optional.of(jdbcColumnTypes.build()), @@ -1075,10 +1069,10 @@ public void commitCreateTable(ConnectorSession session, JdbcOutputTableHandle ha else { renameTable( session, - handle.getCatalogName(), - handle.getSchemaName(), + handle.getRemoteTableName().getCatalogName().orElse(null), + handle.getRemoteTableName().getSchemaName().orElse(null), handle.getTemporaryTableName().orElseThrow(() -> new IllegalStateException("Temporary table name missing")), - new SchemaTableName(handle.getSchemaName(), handle.getTableName())); + handle.getRemoteTableName().getSchemaTableName()); } } @@ -1123,8 +1117,8 @@ private RemoteTableName constructPageSinkIdsTable(ConnectorSession session, Conn verify(handle.getPageSinkIdColumnName().isPresent(), "Output table handle's pageSinkIdColumn is empty"); RemoteTableName pageSinkTable = new RemoteTableName( - Optional.ofNullable(handle.getCatalogName()), - Optional.ofNullable(handle.getSchemaName()), + handle.getRemoteTableName().getCatalogName(), + handle.getRemoteTableName().getSchemaName(), generateTemporaryTableName(session)); int maxBatchSize = getWriteBatchSize(session); @@ -1173,13 +1167,9 @@ public void finishInsertTable(ConnectorSession session, JdbcOutputTableHandle ha } RemoteTableName temporaryTable = new RemoteTableName( - Optional.ofNullable(handle.getCatalogName()), - Optional.ofNullable(handle.getSchemaName()), + handle.getRemoteTableName().getCatalogName(), + handle.getRemoteTableName().getSchemaName(), handle.getTemporaryTableName().orElseThrow()); - RemoteTableName targetTable = new RemoteTableName( - Optional.ofNullable(handle.getCatalogName()), - Optional.ofNullable(handle.getSchemaName()), - handle.getTableName()); // We conditionally create more than the one table, so keep a list of the tables that need to be dropped. Closer closer = Closer.create(); @@ -1192,7 +1182,7 @@ public void finishInsertTable(ConnectorSession session, JdbcOutputTableHandle ha .collect(joining(", ")); String insertSql = format("INSERT INTO %s (%s) SELECT %s FROM %s temp_table", - postProcessInsertTableNameClause(session, quoted(targetTable)), + postProcessInsertTableNameClause(session, quoted(handle.getRemoteTableName())), columns, columns, quoted(temporaryTable)); @@ -1358,8 +1348,8 @@ public void rollbackCreateTable(ConnectorSession session, JdbcOutputTableHandle if (handle.getTemporaryTableName().isPresent()) { dropTable(session, new RemoteTableName( - Optional.ofNullable(handle.getCatalogName()), - Optional.ofNullable(handle.getSchemaName()), + handle.getRemoteTableName().getCatalogName(), + handle.getRemoteTableName().getSchemaName(), handle.getTemporaryTableName().get()), true); } @@ -1383,7 +1373,10 @@ public String buildInsertSql(JdbcOutputTableHandle handle, List c checkArgument(handle.getColumnNames().size() == columnWriters.size(), "handle and columnWriters mismatch: %s, %s", handle, columnWriters); return format( "INSERT INTO %s (%s%s) VALUES (%s%s)", - quoted(handle.getCatalogName(), handle.getSchemaName(), handle.getTemporaryTableName().orElseGet(handle::getTableName)), + quoted( + handle.getRemoteTableName().getCatalogName().orElse(null), + handle.getRemoteTableName().getSchemaName().orElse(null), + handle.getTemporaryTableName().orElseGet(() -> handle.getRemoteTableName().getTableName())), handle.getColumnNames().stream() .map(this::quoted) .collect(joining(", ")), diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/CachingJdbcClient.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/CachingJdbcClient.java index c5fd6fe8ef1a..a5595c27b567 100644 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/CachingJdbcClient.java +++ b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/CachingJdbcClient.java @@ -388,7 +388,7 @@ public JdbcProcedureHandle getProcedureHandle(ConnectorSession session, Procedur public void commitCreateTable(ConnectorSession session, JdbcOutputTableHandle handle, Set pageSinkIds) { delegate.commitCreateTable(session, handle, pageSinkIds); - invalidateTableCaches(new SchemaTableName(handle.getSchemaName(), handle.getTableName())); + invalidateTableCaches(handle.getRemoteTableName().getSchemaTableName()); } @Override @@ -401,7 +401,7 @@ public JdbcOutputTableHandle beginInsertTable(ConnectorSession session, JdbcTabl public void finishInsertTable(ConnectorSession session, JdbcOutputTableHandle handle, Set pageSinkIds) { delegate.finishInsertTable(session, handle, pageSinkIds); - onDataChanged(new SchemaTableName(handle.getSchemaName(), handle.getTableName())); + onDataChanged(handle.getRemoteTableName().getSchemaTableName()); } @Override diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/JdbcOutputTableHandle.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/JdbcOutputTableHandle.java index 91c9f5b0eb05..170661628e6a 100644 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/JdbcOutputTableHandle.java +++ b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/JdbcOutputTableHandle.java @@ -19,22 +19,18 @@ import io.trino.spi.connector.ConnectorInsertTableHandle; import io.trino.spi.connector.ConnectorOutputTableHandle; import io.trino.spi.type.Type; -import jakarta.annotation.Nullable; import java.util.List; import java.util.Objects; import java.util.Optional; import static com.google.common.base.Preconditions.checkArgument; -import static java.lang.String.format; import static java.util.Objects.requireNonNull; public class JdbcOutputTableHandle implements ConnectorOutputTableHandle, ConnectorInsertTableHandle { - private final String catalogName; - private final String schemaName; - private final String tableName; + private final RemoteTableName remoteTableName; private final List columnNames; private final List columnTypes; private final Optional> jdbcColumnTypes; @@ -43,18 +39,14 @@ public class JdbcOutputTableHandle @JsonCreator public JdbcOutputTableHandle( - @JsonProperty("catalogName") @Nullable String catalogName, - @JsonProperty("schemaName") @Nullable String schemaName, - @JsonProperty("tableName") String tableName, + @JsonProperty("remoteTableName") RemoteTableName remoteTableName, @JsonProperty("columnNames") List columnNames, @JsonProperty("columnTypes") List columnTypes, @JsonProperty("jdbcColumnTypes") Optional> jdbcColumnTypes, @JsonProperty("temporaryTableName") Optional temporaryTableName, @JsonProperty("pageSinkIdColumnName") Optional pageSinkIdColumnName) { - this.catalogName = catalogName; - this.schemaName = schemaName; - this.tableName = requireNonNull(tableName, "tableName is null"); + this.remoteTableName = requireNonNull(remoteTableName, "remoteTableName is null"); this.temporaryTableName = requireNonNull(temporaryTableName, "temporaryTableName is null"); requireNonNull(columnNames, "columnNames is null"); @@ -68,23 +60,9 @@ public JdbcOutputTableHandle( } @JsonProperty - @Nullable - public String getCatalogName() + public RemoteTableName getRemoteTableName() { - return catalogName; - } - - @JsonProperty - @Nullable - public String getSchemaName() - { - return schemaName; - } - - @JsonProperty - public String getTableName() - { - return tableName; + return remoteTableName; } @JsonProperty @@ -120,16 +98,14 @@ public Optional getPageSinkIdColumnName() @Override public String toString() { - return format("jdbc:%s.%s.%s", catalogName, schemaName, tableName); + return "jdbc:%s".formatted(remoteTableName); } @Override public int hashCode() { return Objects.hash( - catalogName, - schemaName, - tableName, + remoteTableName, columnNames, columnTypes, jdbcColumnTypes, @@ -147,9 +123,7 @@ public boolean equals(Object obj) return false; } JdbcOutputTableHandle other = (JdbcOutputTableHandle) obj; - return Objects.equals(this.catalogName, other.catalogName) && - Objects.equals(this.schemaName, other.schemaName) && - Objects.equals(this.tableName, other.tableName) && + return Objects.equals(this.remoteTableName, other.remoteTableName) && Objects.equals(this.columnNames, other.columnNames) && Objects.equals(this.columnTypes, other.columnTypes) && Objects.equals(this.jdbcColumnTypes, other.jdbcColumnTypes) && diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/RemoteTableName.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/RemoteTableName.java index 43e6fcdf84a0..bfe67bc6f1af 100644 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/RemoteTableName.java +++ b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/RemoteTableName.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Joiner; +import io.trino.spi.connector.SchemaTableName; import java.util.Objects; import java.util.Optional; @@ -58,6 +59,11 @@ public String getTableName() return tableName; } + public SchemaTableName getSchemaTableName() + { + return new SchemaTableName(schemaName.orElseThrow(), tableName); + } + @Override public boolean equals(Object o) { diff --git a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcOutputTableHandle.java b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcOutputTableHandle.java index 08c855703ee0..5e2bece2839f 100644 --- a/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcOutputTableHandle.java +++ b/plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcOutputTableHandle.java @@ -29,9 +29,7 @@ public class TestJdbcOutputTableHandle public void testJsonRoundTrip() { JdbcOutputTableHandle handleForCreate = new JdbcOutputTableHandle( - "catalog", - "schema", - "table", + new RemoteTableName(Optional.of("catalog"), Optional.of("schema"), "table"), ImmutableList.of("abc", "xyz"), ImmutableList.of(VARCHAR, VARCHAR), Optional.empty(), @@ -41,9 +39,7 @@ public void testJsonRoundTrip() assertJsonRoundTrip(OUTPUT_TABLE_CODEC, handleForCreate); JdbcOutputTableHandle handleForInsert = new JdbcOutputTableHandle( - "catalog", - "schema", - "table", + new RemoteTableName(Optional.of("catalog"), Optional.of("schema"), "table"), ImmutableList.of("abc", "xyz"), ImmutableList.of(VARCHAR, VARCHAR), Optional.of(ImmutableList.of(JDBC_VARCHAR, JDBC_VARCHAR)), diff --git a/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteClient.java b/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteClient.java index 0ead923826d5..34c8183d7886 100644 --- a/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteClient.java +++ b/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteClient.java @@ -37,6 +37,7 @@ import io.trino.plugin.jdbc.LongWriteFunction; import io.trino.plugin.jdbc.PreparedQuery; import io.trino.plugin.jdbc.QueryBuilder; +import io.trino.plugin.jdbc.RemoteTableName; import io.trino.plugin.jdbc.WriteFunction; import io.trino.plugin.jdbc.WriteMapping; import io.trino.plugin.jdbc.aggregation.ImplementAvgFloatingPoint; @@ -415,8 +416,7 @@ public JdbcOutputTableHandle beginCreateTable(ConnectorSession session, Connecto execute(session, connection, sql); return new IgniteOutputTableHandle( - schemaTableName.getSchemaName(), - schemaTableName.getTableName(), + new RemoteTableName(Optional.empty(), Optional.of(schemaTableName.getSchemaName()), schemaTableName.getTableName()), columnNames, columnTypes.build(), Optional.empty(), @@ -568,7 +568,7 @@ public String buildInsertSql(JdbcOutputTableHandle handle, List c } return format( "INSERT INTO %s (%s) VALUES (%s)", - quoted(null, handle.getSchemaName(), handle.getTableName()), + quoted(handle.getRemoteTableName()), columns, params); } diff --git a/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteMetadata.java b/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteMetadata.java index 44b684a8036f..af40e9e0f300 100644 --- a/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteMetadata.java +++ b/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteMetadata.java @@ -104,8 +104,7 @@ public ConnectorInsertTableHandle beginInsert(ConnectorSession session, Connecto RemoteTableName remoteTableName = handle.asPlainTable().getRemoteTableName(); return new IgniteOutputTableHandle( - remoteTableName.getSchemaName().orElse(null), - remoteTableName.getTableName(), + remoteTableName, columnNames.build(), columnTypes.build(), Optional.of(columnJdbcTypeHandles.build()), diff --git a/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteOutputTableHandle.java b/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteOutputTableHandle.java index 185231c1351d..1132aa23e710 100644 --- a/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteOutputTableHandle.java +++ b/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteOutputTableHandle.java @@ -17,8 +17,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import io.trino.plugin.jdbc.JdbcOutputTableHandle; import io.trino.plugin.jdbc.JdbcTypeHandle; +import io.trino.plugin.jdbc.RemoteTableName; import io.trino.spi.type.Type; -import jakarta.annotation.Nullable; import java.util.List; import java.util.Optional; @@ -32,14 +32,13 @@ public class IgniteOutputTableHandle @JsonCreator public IgniteOutputTableHandle( - @Nullable @JsonProperty("schemaName") String schemaName, - @JsonProperty("tableName") String tableName, + @JsonProperty("remoteTableName") RemoteTableName remoteTableName, @JsonProperty("columnNames") List columnNames, @JsonProperty("columnTypes") List columnTypes, @JsonProperty("jdbcColumnTypes") Optional> jdbcColumnTypes, @JsonProperty("dummyIdColumn") Optional dummyIdColumn) { - super("", schemaName, tableName, columnNames, columnTypes, jdbcColumnTypes, Optional.empty(), Optional.empty()); + super(remoteTableName, columnNames, columnTypes, jdbcColumnTypes, Optional.empty(), Optional.empty()); this.dummyIdColumn = requireNonNull(dummyIdColumn, "dummyIdColumn is null"); } diff --git a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java index 809c7fdae23d..7d398e2194eb 100644 --- a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java +++ b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixClient.java @@ -410,13 +410,13 @@ public String buildInsertSql(JdbcOutputTableHandle handle, List c if (outputHandle.rowkeyColumn().isPresent()) { String nextId = format( "NEXT VALUE FOR %s, ", - quoted(null, handle.getSchemaName(), handle.getTableName() + "_sequence")); + quoted(null, handle.getRemoteTableName().getSchemaName().orElse(null), handle.getRemoteTableName().getTableName() + "_sequence")); params = nextId + params; columns = outputHandle.rowkeyColumn().get() + ", " + columns; } return format( "UPSERT INTO %s (%s) VALUES (%s)", - quoted(null, handle.getSchemaName(), handle.getTableName()), + quoted(handle.getRemoteTableName()), columns, params); } @@ -696,8 +696,7 @@ public JdbcOutputTableHandle beginCreateTable(ConnectorSession session, Connecto execute(session, sql); return new PhoenixOutputTableHandle( - schema, - table, + new RemoteTableName(Optional.empty(), Optional.ofNullable(schema), table), columnNames.build(), columnTypes.build(), Optional.empty(), diff --git a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixMergeSink.java b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixMergeSink.java index ad440238408d..197dcf04fb3b 100644 --- a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixMergeSink.java +++ b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixMergeSink.java @@ -19,6 +19,7 @@ import io.trino.plugin.jdbc.JdbcClient; import io.trino.plugin.jdbc.JdbcOutputTableHandle; import io.trino.plugin.jdbc.JdbcPageSink; +import io.trino.plugin.jdbc.RemoteTableName; import io.trino.plugin.jdbc.WriteFunction; import io.trino.plugin.jdbc.logging.RemoteQueryModifier; import io.trino.spi.Page; @@ -50,8 +51,7 @@ public class PhoenixMergeSink implements ConnectorMergeSink { - private final String schemaName; - private final String tableName; + private final RemoteTableName remoteTableName; private final boolean hasRowKey; private final int columnCount; private final List mergeRowIdFieldNames; @@ -64,8 +64,7 @@ public PhoenixMergeSink(PhoenixClient phoenixClient, RemoteQueryModifier remoteQ { PhoenixMergeTableHandle phoenixMergeTableHandle = (PhoenixMergeTableHandle) mergeHandle; PhoenixOutputTableHandle phoenixOutputTableHandle = phoenixMergeTableHandle.phoenixOutputTableHandle(); - this.schemaName = phoenixOutputTableHandle.getSchemaName(); - this.tableName = phoenixOutputTableHandle.getTableName(); + this.remoteTableName = phoenixOutputTableHandle.getRemoteTableName(); this.hasRowKey = phoenixOutputTableHandle.rowkeyColumn().isPresent(); this.columnCount = phoenixOutputTableHandle.getColumnNames().size(); @@ -101,8 +100,7 @@ private ConnectorPageSink createUpdateSink( } PhoenixOutputTableHandle updateOutputTableHandle = new PhoenixOutputTableHandle( - schemaName, - tableName, + remoteTableName, columnNamesBuilder.build(), columnTypesBuilder.build(), Optional.empty(), @@ -119,8 +117,7 @@ private ConnectorPageSink createDeleteSink( { checkArgument(mergeRowIdFieldNames.size() == mergeRowIdFieldTypes.size(), "Wrong merge row column, columns and types size not match"); JdbcOutputTableHandle deleteOutputTableHandle = new PhoenixOutputTableHandle( - schemaName, - tableName, + remoteTableName, mergeRowIdFieldNames, mergeRowIdFieldTypes, Optional.empty(), @@ -146,7 +143,7 @@ protected String getSinkSql(JdbcClient jdbcClient, JdbcOutputTableHandle outputT checkArgument(!conjuncts.isEmpty(), "Merge row id fields should not empty"); String whereCondition = Joiner.on(" AND ").join(conjuncts); - return format("DELETE FROM %s.%s WHERE %s", schemaName, tableName, whereCondition); + return format("DELETE FROM %s.%s WHERE %s", remoteTableName.getSchemaName().orElseThrow(), remoteTableName.getTableName(), whereCondition); } } diff --git a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixMetadata.java b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixMetadata.java index 7764834dbf71..45ba5c6b9e8e 100644 --- a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixMetadata.java +++ b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixMetadata.java @@ -238,8 +238,7 @@ public ConnectorInsertTableHandle beginInsert(ConnectorSession session, Connecto RemoteTableName remoteTableName = handle.asPlainTable().getRemoteTableName(); return new PhoenixOutputTableHandle( - remoteTableName.getSchemaName().orElse(null), - remoteTableName.getTableName(), + remoteTableName, columnHandles.stream().map(JdbcColumnHandle::getColumnName).collect(toImmutableList()), columnHandles.stream().map(JdbcColumnHandle::getColumnType).collect(toImmutableList()), Optional.of(columnHandles.stream().map(JdbcColumnHandle::getJdbcTypeHandle).collect(toImmutableList())), diff --git a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixOutputTableHandle.java b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixOutputTableHandle.java index e43f95b9cb1c..7b00902262ae 100644 --- a/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixOutputTableHandle.java +++ b/plugin/trino-phoenix5/src/main/java/io/trino/plugin/phoenix5/PhoenixOutputTableHandle.java @@ -17,8 +17,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import io.trino.plugin.jdbc.JdbcOutputTableHandle; import io.trino.plugin.jdbc.JdbcTypeHandle; +import io.trino.plugin.jdbc.RemoteTableName; import io.trino.spi.type.Type; -import jakarta.annotation.Nullable; import java.util.List; import java.util.Optional; @@ -32,14 +32,13 @@ public class PhoenixOutputTableHandle @JsonCreator public PhoenixOutputTableHandle( - @Nullable @JsonProperty("schemaName") String schemaName, - @JsonProperty("tableName") String tableName, + @JsonProperty("remoteTableName") RemoteTableName remoteTableName, @JsonProperty("columnNames") List columnNames, @JsonProperty("columnTypes") List columnTypes, @JsonProperty("jdbcColumnTypes") Optional> jdbcColumnTypes, @JsonProperty("rowkeyColumn") Optional rowkeyColumn) { - super("", schemaName, tableName, columnNames, columnTypes, jdbcColumnTypes, Optional.empty(), Optional.empty()); + super(remoteTableName, columnNames, columnTypes, jdbcColumnTypes, Optional.empty(), Optional.empty()); this.rowkeyColumn = requireNonNull(rowkeyColumn, "rowkeyColumn is null"); } diff --git a/plugin/trino-sqlserver/src/main/java/io/trino/plugin/sqlserver/SqlServerClient.java b/plugin/trino-sqlserver/src/main/java/io/trino/plugin/sqlserver/SqlServerClient.java index 849890dcc70a..396880e75da3 100644 --- a/plugin/trino-sqlserver/src/main/java/io/trino/plugin/sqlserver/SqlServerClient.java +++ b/plugin/trino-sqlserver/src/main/java/io/trino/plugin/sqlserver/SqlServerClient.java @@ -379,7 +379,10 @@ protected void enableTableLockOnBulkLoadTableOption(ConnectorSession session, Jd // 'table lock on bulk load' table option causes the bulk load processes on user-defined tables to obtain a bulk update lock // note: this is not a request to lock a table immediately String sql = format("EXEC sp_tableoption '%s', 'table lock on bulk load', '1'", - quoted(table.getCatalogName(), table.getSchemaName(), table.getTemporaryTableName().orElseGet(table::getTableName))); + quoted( + table.getRemoteTableName().getCatalogName().orElse(null), + table.getRemoteTableName().getSchemaName().orElse(null), + table.getTemporaryTableName().orElseGet(() -> table.getRemoteTableName().getTableName()))); execute(session, connection, sql); } catch (SQLException e) {