crepererum commented on code in PR #13343:
URL: https://github.com/apache/datafusion/pull/13343#discussion_r1836412936
##########
datafusion/substrait/src/logical_plan/consumer.rs:
##########
@@ -841,16 +836,35 @@ pub async fn from_substrait_rel(
left.cross_join(right.build()?)?.build()
}
Some(RelType::Read(read)) => {
- fn read_with_schema(
- df: DataFrame,
+ async fn read_with_schema(
+ ctx: &SessionState,
+ table_ref: TableReference,
schema: DFSchema,
projection: &Option<MaskExpression>,
) -> Result<LogicalPlan> {
- ensure_schema_compatability(df.schema().to_owned(),
schema.clone())?;
+ let schema = schema.replace_qualifier(table_ref.clone());
+
+ let plan = {
+ let table = table_ref.table().to_string();
+ let schema = ctx.schema_for_ref(table_ref.clone())?;
+ let provider = match schema.table(&table).await? {
+ Some(ref provider) => Arc::clone(provider),
+ _ => return plan_err!("No table named '{table}'"),
+ };
+
+ LogicalPlanBuilder::scan(
+ table_ref,
+ provider_as_source(Arc::clone(&provider)),
+ None,
+ )?
Review Comment:
I think this might make sense to deduplicate this code, esp. since it also
contains sanity checks that we don't want to miss or misalign.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]