Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support time travel on Iceberg system tables #12736

Closed
findinpath opened this issue Jun 8, 2022 · 1 comment
Closed

Support time travel on Iceberg system tables #12736

findinpath opened this issue Jun 8, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@findinpath
Copy link
Contributor

The following versioned query works OK:

select * from "icebergtable$files@7046541185529900854";

However the query:

select * from "icebergtable$files" for version as of 7046541185529900854;

fails with the exception:

io.trino.spi.TrinoException: This connector does not support versioned tables
	at io.trino.spi.connector.ConnectorMetadata.isSupportedVersionType(ConnectorMetadata.java:1319)
	at io.trino.metadata.MetadataManager.isValidTableVersion(MetadataManager.java:2415)
	at io.trino.sql.analyzer.StatementAnalyzer$Visitor.extractTableVersion(StatementAnalyzer.java:4579)
	at io.trino.sql.analyzer.StatementAnalyzer$Visitor.getTableHandle(StatementAnalyzer.java:4543)
	at io.trino.sql.analyzer.StatementAnalyzer$Visitor.visitTable(StatementAnalyzer.java:1771)
	at io.trino.sql.analyzer.StatementAnalyzer$Visitor.visitTable(StatementAnalyzer.java:436)
	at io.trino.sql.tree.Table.accept(Table.java:60)
	at io.trino.sql.tree.AstVisitor.process(AstVisitor.java:27)
	at io.trino.sql.analyzer.StatementAnalyzer$Visitor.process(StatementAnalyzer.java:453)
	at io.trino.sql.analyzer.StatementAnalyzer$Visitor.analyzeFrom(StatementAnalyzer.java:3666)
	at io.trino.sql.analyzer.StatementAnalyzer$Visitor.visitQuerySpecification(StatementAnalyzer.java:2405)
	at io.trino.sql.analyzer.StatementAnalyzer$Visitor.visitQuerySpecification(StatementAnalyzer.java:436)
	at io.trino.sql.tree.QuerySpecification.accept(QuerySpecification.java:155)
	at io.trino.sql.tree.AstVisitor.process(AstVisitor.java:27)
	at io.trino.sql.analyzer.StatementAnalyzer$Visitor.process(StatementAnalyzer.java:453)
	at io.trino.sql.analyzer.StatementAnalyzer$Visitor.process(StatementAnalyzer.java:461)
	at io.trino.sql.analyzer.StatementAnalyzer$Visitor.visitQuery(StatementAnalyzer.java:1377)
	at io.trino.sql.analyzer.StatementAnalyzer$Visitor.visitQuery(StatementAnalyzer.java:436)

The problem is lied to the fact that "icebergtable$files" translates to SystemTablesMetadata which has no implementation for the method io.trino.spi.connector.ConnectorMetadata#isSupportedVersionType

In any case extracting the start version and end version shouldn't be done in StatementAnalyzer but in IcebergMetadata

if (table.getQueryPeriod().isPresent()) {
Optional<TableVersion> startVersion = extractTableVersion(table, name, table.getQueryPeriod().get().getStart(), scope);
Optional<TableVersion> endVersion = extractTableVersion(table, name, table.getQueryPeriod().get().getEnd(), scope);
return metadata.getRedirectionAwareTableHandle(session, name, startVersion, endVersion);

Also SystemTablesMetadata should have an implementation for the interface method getTableHandle(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.SchemaTableName, java.util.Optional<io.trino.spi.connector.ConnectorTableVersion>, java.util.Optional<io.trino.spi.connector.ConnectorTableVersion>)

@electrum
Copy link
Member

I don't think we want to extend SystemTable any further. Now that we allow multiple table handles, that seems like a more straightforward approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment