SteNicholas commented on code in PR #1448:
URL: https://github.com/apache/paimon-rust/pull/1448#discussion_r4657828128
##########
crates/integrations/datafusion/src/relation_planner.rs:
##########
@@ -39,6 +39,31 @@ use crate::catalog::{
};
use crate::table::{ObjectTableProvider, PaimonTableProvider};
+/// Resolves statement-local TABLE bindings to snapshot scans with the
original table qualifier.
+#[derive(Debug)]
+pub(crate) struct SnapshotRelationPlanner(
+ pub HashMap<String, (TableReference, Arc<dyn TableProvider>)>,
+);
+
+impl RelationPlanner for SnapshotRelationPlanner {
+ fn plan_relation(
+ &self,
+ relation: TableFactor,
+ _: &mut dyn RelationPlannerContext,
+ ) -> DFResult<RelationPlanning> {
+ if let TableFactor::TableFunction {
+ expr: ast::Expr::Identifier(binding),
+ alias,
+ } = &relation
+ {
+ if let Some((table, provider)) = self.0.get(&binding.value) {
+ return plan_scan(alias.clone(), table.clone(),
provider.clone());
Review Comment:
Snapshot scans whose qualifiers collide now receive distinct bindings within
the query scope. Explicit aliases and SQL-visible column names are preserved
across joins, CTEs and subqueries. With three rows in version 1 and five in
version 2, the regression verifies that `JOIN ... USING (id)` returns three
matches and that a right anti join finds the two rows introduced in version 2.
[Snapshot-join
regressions](https://github.com/apache/paimon-rust/blob/da3a9470841313239f6c1daea182f4882718badc/crates/integrations/datafusion/tests/time_travel_schema_tests.rs#L229-L300)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]