(
&self,
relation: TableFactor,
context: &mut dyn RelationPlannerContext,
)
| 56 | |
| 57 | impl RelationPlanner for PaimonRelationPlanner { |
| 58 | fn plan_relation( |
| 59 | &self, |
| 60 | relation: TableFactor, |
| 61 | context: &mut dyn RelationPlannerContext, |
| 62 | ) -> DFResult<RelationPlanning> { |
| 63 | // Only handle Table factors with a version clause. |
| 64 | let TableFactor::Table { |
| 65 | ref name, |
| 66 | ref version, |
| 67 | .. |
| 68 | } = relation |
| 69 | else { |
| 70 | return Ok(RelationPlanning::Original(Box::new(relation))); |
| 71 | }; |
| 72 | |
| 73 | let extra_options = match version { |
| 74 | Some(TableVersion::VersionAsOf(expr)) => resolve_version_as_of(expr)?, |
| 75 | Some(TableVersion::TimestampAsOf(expr)) => resolve_timestamp_as_of(expr)?, |
| 76 | _ => return Ok(RelationPlanning::Original(Box::new(relation))), |
| 77 | }; |
| 78 | |
| 79 | // Resolve the table reference. |
| 80 | let table_ref = object_name_to_table_reference(name, context)?; |
| 81 | let source = context |
| 82 | .context_provider() |
| 83 | .get_table_source(table_ref.clone())?; |
| 84 | let provider = source_as_provider(&source)?; |
| 85 | |
| 86 | // Check if this is a Paimon table. |
| 87 | let Some(paimon_provider) = provider.as_any().downcast_ref::<PaimonTableProvider>() else { |
| 88 | return Ok(RelationPlanning::Original(Box::new(relation))); |
| 89 | }; |
| 90 | |
| 91 | let new_table = paimon_provider.table().copy_with_options(extra_options); |
| 92 | let new_provider = PaimonTableProvider::try_new(new_table)?; |
| 93 | let new_source = provider_as_source(Arc::new(new_provider)); |
| 94 | |
| 95 | // Destructure to get alias. |
| 96 | let TableFactor::Table { alias, .. } = relation else { |
| 97 | unreachable!() |
| 98 | }; |
| 99 | |
| 100 | let plan = LogicalPlanBuilder::scan(table_ref, new_source, None)?.build()?; |
| 101 | Ok(RelationPlanning::Planned(Box::new(PlannedRelation::new( |
| 102 | plan, alias, |
| 103 | )))) |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | /// Convert a sqlparser `ObjectName` to a DataFusion `TableReference`. |
nothing calls this directly
no test coverage detected