Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import io.trino.spi.connector.ConnectorViewDefinition;
import io.trino.spi.connector.MaterializedViewFreshness;
import io.trino.spi.connector.MaterializedViewNotFoundException;
import io.trino.spi.connector.RetryMode;
import io.trino.spi.connector.SchemaTableName;
import io.trino.spi.connector.SchemaTablePrefix;
import io.trino.spi.connector.ViewNotFoundException;
Expand Down Expand Up @@ -276,7 +277,7 @@ public void markMaterializedViewIsFresh(SchemaTableName name)
}

@Override
public ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional<ConnectorTableLayout> layout)
public ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional<ConnectorTableLayout> layout, RetryMode retryMode)
{
createTable(session, tableMetadata, false);
return TestingHandle.INSTANCE;
Expand All @@ -289,7 +290,7 @@ public Optional<ConnectorOutputMetadata> finishCreateTable(ConnectorSession sess
}

@Override
public ConnectorInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle)
public ConnectorInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle, List<ColumnHandle> columns, RetryMode retryMode)
{
return TestingHandle.INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import io.trino.spi.connector.MaterializedViewFreshness;
import io.trino.spi.connector.ProjectionApplicationResult;
import io.trino.spi.connector.RecordPageSource;
import io.trino.spi.connector.RetryMode;
import io.trino.spi.connector.SchemaTableName;
import io.trino.spi.connector.SchemaTablePrefix;
import io.trino.spi.connector.SortItem;
Expand Down Expand Up @@ -516,7 +517,7 @@ public CompletableFuture<?> refreshMaterializedView(ConnectorSession session, Sc
}

@Override
public ConnectorInsertTableHandle beginRefreshMaterializedView(ConnectorSession session, ConnectorTableHandle tableHandle, List<ConnectorTableHandle> sourceTableHandles)
public ConnectorInsertTableHandle beginRefreshMaterializedView(ConnectorSession session, ConnectorTableHandle tableHandle, List<ConnectorTableHandle> sourceTableHandles, RetryMode retryMode)
{
return new MockConnectorInsertTableHandle(((MockConnectorTableHandle) tableHandle).getTableName());
}
Expand Down Expand Up @@ -552,7 +553,7 @@ public Optional<ConnectorViewDefinition> getView(ConnectorSession session, Schem
}

@Override
public ConnectorInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle, List<ColumnHandle> columns)
public ConnectorInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle, List<ColumnHandle> columns, RetryMode retryMode)
{
return new MockConnectorInsertTableHandle(((MockConnectorTableHandle) tableHandle).getTableName());
}
Expand All @@ -577,7 +578,7 @@ public Optional<ConnectorTableLayout> getInsertLayout(ConnectorSession session,
}

@Override
public ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional<ConnectorTableLayout> layout)
public ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional<ConnectorTableLayout> layout, RetryMode retryMode)
{
return new MockConnectorOutputTableHandle(tableMetadata.getTable());
}
Expand All @@ -595,7 +596,7 @@ public Optional<ConnectorTableLayout> getNewTableLayout(ConnectorSession session
}

@Override
public ConnectorTableHandle beginUpdate(ConnectorSession session, ConnectorTableHandle tableHandle, List<ColumnHandle> updatedColumns)
public ConnectorTableHandle beginUpdate(ConnectorSession session, ConnectorTableHandle tableHandle, List<ColumnHandle> updatedColumns, RetryMode retryMode)
{
return tableHandle;
}
Expand All @@ -610,7 +611,7 @@ public ColumnHandle getUpdateRowIdColumnHandle(ConnectorSession session, Connect
}

@Override
public ConnectorTableHandle beginDelete(ConnectorSession session, ConnectorTableHandle tableHandle)
public ConnectorTableHandle beginDelete(ConnectorSession session, ConnectorTableHandle tableHandle, RetryMode retryMode)
{
return tableHandle;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,12 @@ default ConnectorTableHandle getTableHandleForStatisticsCollection(ConnectorSess
* Create initial handle for execution of table procedure. The handle will be used through planning process. It will be converted to final
* handle used for execution via @{link {@link ConnectorMetadata#beginTableExecute}
*
* @deprecated Use {@link #getTableHandleForExecute(ConnectorSession, ConnectorTableHandle, String, Map, RetryMode)} instead.
*/
@Deprecated
default Optional<ConnectorTableExecuteHandle> getTableHandleForExecute(
ConnectorSession session,
ConnectorTableHandle tableHandle,
String procedureName,
Map<String, Object> executeProperties)
{
throw new TrinoException(NOT_SUPPORTED, "This connector does not support table procedures");
}

/**
* Create initial handle for execution of table procedure. The handle will be used through planning process. It will be converted to final
* handle used for execution via @{link {@link ConnectorMetadata#beginTableExecute}
* <p/>
* If connector does not support execution with retries, the method should throw:
* <pre>
* new TrinoException(NOT_SUPPORTED, "This connector does not support query retries")
* </pre>
* unless {@code retryMode} is set to {@code NO_RETRIES}.
*/
default Optional<ConnectorTableExecuteHandle> getTableHandleForExecute(
ConnectorSession session,
Expand All @@ -119,10 +110,7 @@ default Optional<ConnectorTableExecuteHandle> getTableHandleForExecute(
Map<String, Object> executeProperties,
RetryMode retryMode)
{
if (retryMode != RetryMode.NO_RETRIES) {
throw new TrinoException(NOT_SUPPORTED, "This connector does not support query retries");
}
return getTableHandleForExecute(session, tableHandle, procedureName, executeProperties);
throw new TrinoException(NOT_SUPPORTED, "This connector does not support table procedures");
}

default Optional<ConnectorTableLayout> getLayoutForTableExecute(ConnectorSession session, ConnectorTableExecuteHandle tableExecuteHandle)
Expand Down Expand Up @@ -484,23 +472,16 @@ default void finishStatisticsCollection(ConnectorSession session, ConnectorTable
/**
* Begin the atomic creation of a table with data.
*
* @deprecated Use {@link #beginCreateTable(ConnectorSession, ConnectorTableMetadata, Optional, RetryMode)}
*/
@Deprecated
default ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional<ConnectorTableLayout> layout)
{
throw new TrinoException(NOT_SUPPORTED, "This connector does not support creating tables with data");
}

/**
* Begin the atomic creation of a table with data.
* <p/>
* If connector does not support execution with retries, the method should throw:
* <pre>
* new TrinoException(NOT_SUPPORTED, "This connector does not support query retries")
* </pre>
* unless {@code retryMode} is set to {@code NO_RETRIES}.
*/
default ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional<ConnectorTableLayout> layout, RetryMode retryMode)
{
if (retryMode != RetryMode.NO_RETRIES) {
throw new TrinoException(NOT_SUPPORTED, "This connector does not support query retries");
}
return beginCreateTable(session, tableMetadata, layout);
throw new TrinoException(NOT_SUPPORTED, "This connector does not support creating tables with data");
}

/**
Expand All @@ -525,34 +506,16 @@ default void cleanupQuery(ConnectorSession session) {}
/**
* Begin insert query.
*
* @deprecated Use {@link #beginInsert(ConnectorSession, ConnectorTableHandle, List, RetryMode)} instead.
*/
@Deprecated
default ConnectorInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle)
{
throw new TrinoException(NOT_SUPPORTED, "This connector does not support inserts");
}

/**
* Begin insert query.
*
* @deprecated Use {@link #beginInsert(ConnectorSession, ConnectorTableHandle, List, RetryMode)} instead.
*/
@Deprecated
default ConnectorInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle, List<ColumnHandle> columns)
{
return beginInsert(session, tableHandle);
}

/**
* Begin insert query.
* <p/>
* If connector does not support execution with retries, the method should throw:
* <pre>
* new TrinoException(NOT_SUPPORTED, "This connector does not support query retries")
* </pre>
* unless {@code retryMode} is set to {@code NO_RETRIES}.
*/
default ConnectorInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle, List<ColumnHandle> columns, RetryMode retryMode)
{
if (retryMode != RetryMode.NO_RETRIES) {
throw new TrinoException(NOT_SUPPORTED, "This connector does not support query retries");
}
return beginInsert(session, tableHandle, columns);
throw new TrinoException(NOT_SUPPORTED, "This connector does not support inserts");
}

/**
Expand Down Expand Up @@ -590,23 +553,16 @@ default CompletableFuture<?> refreshMaterializedView(ConnectorSession session, S
/**
* Begin materialized view query.
*
* @deprecated Use {@link #beginRefreshMaterializedView(ConnectorSession, ConnectorTableHandle, List, RetryMode)} instead.
*/
@Deprecated
default ConnectorInsertTableHandle beginRefreshMaterializedView(ConnectorSession session, ConnectorTableHandle tableHandle, List<ConnectorTableHandle> sourceTableHandles)
{
throw new TrinoException(NOT_SUPPORTED, "This connector does not support materialized views");
}

/**
* Begin materialized view query.
* <p/>
* If connector does not support execution with retries, the method should throw:
* <pre>
* new TrinoException(NOT_SUPPORTED, "This connector does not support query retries")
* </pre>
* unless {@code retryMode} is set to {@code NO_RETRIES}.
*/
default ConnectorInsertTableHandle beginRefreshMaterializedView(ConnectorSession session, ConnectorTableHandle tableHandle, List<ConnectorTableHandle> sourceTableHandles, RetryMode retryMode)
{
if (retryMode != RetryMode.NO_RETRIES) {
throw new TrinoException(NOT_SUPPORTED, "This connector does not support query retries");
}
return beginRefreshMaterializedView(session, tableHandle, sourceTableHandles);
throw new TrinoException(NOT_SUPPORTED, "This connector does not support materialized views");
}

/**
Expand Down Expand Up @@ -646,23 +602,16 @@ default ColumnHandle getUpdateRowIdColumnHandle(ConnectorSession session, Connec
/**
* Begin delete query.
*
* @deprecated Use {@link #beginDelete(ConnectorSession, ConnectorTableHandle, RetryMode)}
*/
@Deprecated
default ConnectorTableHandle beginDelete(ConnectorSession session, ConnectorTableHandle tableHandle)
{
throw new TrinoException(NOT_SUPPORTED, "This connector does not support deletes");
}

/**
* Begin delete query.
* <p/>
* If connector does not support execution with retries, the method should throw:
* <pre>
* new TrinoException(NOT_SUPPORTED, "This connector does not support query retries")
* </pre>
* unless {@code retryMode} is set to {@code NO_RETRIES}.
*/
default ConnectorTableHandle beginDelete(ConnectorSession session, ConnectorTableHandle tableHandle, RetryMode retryMode)
{
if (retryMode != RetryMode.NO_RETRIES) {
throw new TrinoException(NOT_SUPPORTED, "This connector does not support query retries");
}
return beginDelete(session, tableHandle);
throw new TrinoException(NOT_SUPPORTED, "This connector does not support deletes");
}

/**
Expand All @@ -679,23 +628,12 @@ default void finishDelete(ConnectorSession session, ConnectorTableHandle tableHa
* Do whatever is necessary to start an UPDATE query, returning the {@link ConnectorTableHandle}
* instance that will be passed to split generation, and to the {@link #finishUpdate} method.
*
* @param session The session in which to start the update operation.
* @param tableHandle A ConnectorTableHandle for the table to be updated.
* @param updatedColumns A list of the ColumnHandles of columns that will be updated by this UPDATE
* operation, in table column order.
* @return a ConnectorTableHandle that will be passed to split generation, and to the
* {@link #finishUpdate} method.
* @deprecated Use {@link #beginUpdate(ConnectorSession, ConnectorTableHandle, List, RetryMode)} instead.
*/
@Deprecated
default ConnectorTableHandle beginUpdate(ConnectorSession session, ConnectorTableHandle tableHandle, List<ColumnHandle> updatedColumns)
{
throw new TrinoException(NOT_SUPPORTED, "This connector does not support updates");
}

/**
* Do whatever is necessary to start an UPDATE query, returning the {@link ConnectorTableHandle}
* instance that will be passed to split generation, and to the {@link #finishUpdate} method.
* <p/>
* If connector does not support execution with retries, the method should throw:
* <pre>
* new TrinoException(NOT_SUPPORTED, "This connector does not support query retries")
* </pre>
* unless {@code retryMode} is set to {@code NO_RETRIES}.
*
* @param session The session in which to start the update operation.
* @param tableHandle A ConnectorTableHandle for the table to be updated.
Expand All @@ -706,10 +644,7 @@ default ConnectorTableHandle beginUpdate(ConnectorSession session, ConnectorTabl
*/
default ConnectorTableHandle beginUpdate(ConnectorSession session, ConnectorTableHandle tableHandle, List<ColumnHandle> updatedColumns, RetryMode retryMode)
{
if (retryMode != RetryMode.NO_RETRIES) {
throw new TrinoException(NOT_SUPPORTED, "This connector does not support query retries");
}
return beginUpdate(session, tableHandle, updatedColumns);
throw new TrinoException(NOT_SUPPORTED, "This connector does not support updates");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,6 @@ public ConnectorTableHandle getTableHandleForStatisticsCollection(ConnectorSessi
}
}

@Override
public Optional<ConnectorTableExecuteHandle> getTableHandleForExecute(ConnectorSession session, ConnectorTableHandle tableHandle, String procedureName, Map<String, Object> executeProperties)
{
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
return delegate.getTableHandleForExecute(session, tableHandle, procedureName, executeProperties);
}
}

@Override
public Optional<ConnectorTableExecuteHandle> getTableHandleForExecute(ConnectorSession session, ConnectorTableHandle tableHandle, String procedureName, Map<String, Object> executeProperties, RetryMode retryMode)
{
Expand Down Expand Up @@ -457,14 +449,6 @@ public void setColumnComment(ConnectorSession session, ConnectorTableHandle tabl
}
}

@Override
public ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional<ConnectorTableLayout> layout)
{
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
return delegate.beginCreateTable(session, tableMetadata, layout);
}
}

@Override
public ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional<ConnectorTableLayout> layout, RetryMode retryMode)
{
Expand Down Expand Up @@ -497,22 +481,6 @@ public void cleanupQuery(ConnectorSession session)
}
}

@Override
public ConnectorInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle)
{
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
return delegate.beginInsert(session, tableHandle);
}
}

@Override
public ConnectorInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle, List<ColumnHandle> columns)
{
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
return delegate.beginInsert(session, tableHandle, columns);
}
}

@Override
public ConnectorInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle, List<ColumnHandle> columns, RetryMode retryMode)
{
Expand Down Expand Up @@ -553,14 +521,6 @@ public CompletableFuture<?> refreshMaterializedView(ConnectorSession session, Sc
}
}

@Override
public ConnectorInsertTableHandle beginRefreshMaterializedView(ConnectorSession session, ConnectorTableHandle tableHandle, List<ConnectorTableHandle> sourceTableHandles)
{
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
return delegate.beginRefreshMaterializedView(session, tableHandle, sourceTableHandles);
}
}

@Override
public ConnectorInsertTableHandle beginRefreshMaterializedView(ConnectorSession session, ConnectorTableHandle tableHandle, List<ConnectorTableHandle> sourceTableHandles, RetryMode retryMode)
{
Expand Down Expand Up @@ -671,14 +631,6 @@ public ColumnHandle getUpdateRowIdColumnHandle(ConnectorSession session, Connect
}
}

@Override
public ConnectorTableHandle beginDelete(ConnectorSession session, ConnectorTableHandle tableHandle)
{
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
return delegate.beginDelete(session, tableHandle);
}
}

@Override
public ConnectorTableHandle beginDelete(ConnectorSession session, ConnectorTableHandle tableHandle, RetryMode retryMode)
{
Expand Down Expand Up @@ -1025,14 +977,6 @@ public Optional<TableScanRedirectApplicationResult> applyTableScanRedirect(Conne
}
}

@Override
public ConnectorTableHandle beginUpdate(ConnectorSession session, ConnectorTableHandle tableHandle, List<ColumnHandle> updatedColumns)
{
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
return delegate.beginUpdate(session, tableHandle, updatedColumns);
}
}

@Override
public ConnectorTableHandle beginUpdate(ConnectorSession session, ConnectorTableHandle tableHandle, List<ColumnHandle> updatedColumns, RetryMode retryMode)
{
Expand Down
Loading