Description
https://github.com/apache/spark/pull/34497 added AS OF syntax support to support time travel queries in SQL. When resolving these we cache the resolved relation with only the qualified table name as the key, ignoring the time travel spec. Thus any subsequent queries on that table are resolved using the first's time travel spec.
This affects subqueries, CTEs, and temporary views (when created with SQL).
Queries like this will be incorrectly resolved:
select * from table version as of 1 union all select * from table version as of 0
--->
select * from table version as of 1 union all select * from table version as of 1
This was originally reported here https://github.com/delta-io/delta/issues/1479