eliot1480 commented on code in PR #23672:
URL: https://github.com/apache/datafusion/pull/23672#discussion_r3624828861
##########
datafusion/substrait/src/logical_plan/consumer/rel/read_rel.rs:
##########
@@ -145,30 +132,65 @@ pub async fn from_read_rel(
}));
}
- let values = if !vt.expressions.is_empty() {
- let mut exprs = vec![];
- for row in &vt.expressions {
- let mut row_exprs = vec![];
- for expression in &row.fields {
- let expr = consumer
- .consume_expression(expression, &substrait_schema)
- .await?;
- row_exprs.push(expr);
- }
- // For expressions, validate against top-level schema
fields, not nested names
- if row_exprs.len() != substrait_schema.fields().len() {
- return substrait_err!(
- "Field count mismatch: expected {} fields but
found {} in virtual table row",
- substrait_schema.fields().len(),
- row_exprs.len()
- );
- }
- exprs.push(row_exprs);
+ if vt.expressions.is_empty() {
+ return Ok(LogicalPlan::EmptyRelation(EmptyRelation {
+ produce_one_row: false,
+ schema: DFSchemaRef::new(substrait_schema),
+ }));
+ }
+
+ let mut values = vec![];
+ for row in &vt.expressions {
+ if row.fields.len() != substrait_schema.fields().len() {
+ return substrait_err!(
+ "Field count mismatch: expected {} fields but found {}
in virtual table row",
+ substrait_schema.fields().len(),
+ row.fields.len()
+ );
}
- exprs
- } else {
- convert_literal_rows(consumer, vt, named_struct)?
- };
+
+ let mut row_exprs = vec![];
+ let mut name_idx = 0;
+ for (field_idx, expression) in row.fields.iter().enumerate() {
+ let expr = match expression.rex_type.as_ref() {
+
Some(substrait::proto::expression::RexType::Literal(lit)) => {
Review Comment:
Sounds good! I reverted the changes to consumer/rels/read_rels.rs and added
a small fix that lets the expressions-based VirtualTable rows preserve field
names for both literal and non-literal cells 👍
--
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]