Skip to content
Closed
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 @@ -40,6 +40,7 @@
import io.prestosql.spi.connector.SchemaTableName;
import io.prestosql.spi.connector.SchemaTablePrefix;
import io.prestosql.spi.connector.SystemTable;
import io.prestosql.spi.connector.TableToken;
import io.prestosql.spi.expression.ConnectorExpression;
import io.prestosql.spi.predicate.TupleDomain;
import io.prestosql.spi.security.GrantInfo;
Expand Down Expand Up @@ -677,4 +678,20 @@ public void validateScan(ConnectorSession session, ConnectorTableHandle handle)
delegate.validateScan(session, handle);
}
}

@Override
public Optional<TableToken> getTableToken(ConnectorSession session, ConnectorTableHandle tableHandle, TupleDomain<ColumnHandle> predicate)
{
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
return delegate.getTableToken(session, tableHandle, predicate);
}
}

@Override
public boolean isTableCurrent(ConnectorSession session, ConnectorTableHandle tableHandle, Optional<TableToken> tableToken, TupleDomain<ColumnHandle> predicate)
{
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
return delegate.isTableCurrent(session, tableHandle, tableToken, predicate);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -823,4 +823,27 @@ default Optional<ConnectorTableHandle> applySample(ConnectorSession session, Con
* <p>
*/
default void validateScan(ConnectorSession session, ConnectorTableHandle handle) {}

/**
* API to determine if a table state (data in the table) has changed compared to cached table state in Presto.
* The cached table in Presto may take the form of result cache or a materialized view.
*/
/**
* Method to request the connector for a token that captures the state of the table given the filters.
* Engine does not interpret the token in any way. It simply presents it back to the connector to determine freshness of the cached table
* the token is associated with.
*/
default Optional<TableToken> getTableToken(ConnectorSession session, ConnectorTableHandle tableHandle, TupleDomain<ColumnHandle> predicate)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The predicate should be unnecessary. The table handle should encompass all the pushed down predicates, projections or other more complex operations via the applyXXX calls.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. The 'predicate' parameter is not necessary.

{
return Optional.empty();
}

/**
* Method for the engine to present a table token and applied predicates to request the connector to evaluate if the cached table
* is fresh compared to the actual table state.
*/
default boolean isTableCurrent(ConnectorSession session, ConnectorTableHandle tableHandle, Optional<TableToken> tableToken, TupleDomain<ColumnHandle> predicate)
{
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.prestosql.spi.connector;

public interface TableToken
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be long term, stable, serializable?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that the connector provides the token for each base table when the matview is refreshed. This token needs to be stored somewhere (mat view properties or in the snapshot of storage table if it is an iceberg table). So, you are right this token needs to be serializable.
Since the engine does not interpret the token and simply hands back to the connector to check if view is current, I think the versioning of the token can be managed by the connector. Is this what you meant by 'long term, stable'?

{
}