vbarua commented on code in PR #23672:
URL: https://github.com/apache/datafusion/pull/23672#discussion_r3670061329
##########
datafusion/substrait/src/logical_plan/consumer/rel/read_rel.rs:
##########
@@ -148,19 +148,52 @@ pub async fn from_read_rel(
let values = if !vt.expressions.is_empty() {
let mut exprs = 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()
+ );
+ }
+
let mut row_exprs = vec![];
- for expression in &row.fields {
- let expr = consumer
- .consume_expression(expression, &substrait_schema)
- .await?;
+ 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)) => {
+ if !named_struct.names.is_empty() {
+ name_idx += 1; // top-level names are
provided through schema
+ }
+ Expr::Literal(
+ from_substrait_literal(
+ consumer,
+ lit,
+ &named_struct.names,
+ &mut name_idx,
+ )?,
+ None,
+ )
+ }
+ _ => {
+ rename_field(
+ substrait_schema.field(field_idx).as_ref(),
+ &named_struct.names,
+ field_idx,
+ &mut name_idx,
+ )?;
Review Comment:
We're calling `rename_field` here, but we're dropping the returned field.
Are we just calling this to advanced `name_idx`? I think we can do that
directly.
--
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]