lorenarosati opened a new issue, #16363:
URL: https://github.com/apache/datafusion/issues/16363

   ### Describe the bug
   
   When we convert a Substrait plan (which includes a virtual table) to a 
DataFusion LogicalPlan using the `from_substrait_plan()` 
[function](https://github.com/apache/datafusion/blob/3a312a9976432e705f69ab6b6be2f49889eeb89b/datafusion/substrait/src/logical_plan/consumer/plan.rs#L28),
 the 
[function](https://github.com/apache/datafusion/blob/3a312a9976432e705f69ab6b6be2f49889eeb89b/datafusion/substrait/src/logical_plan/consumer/rel/read_rel.rs#L39)
 `from_read_rel()` is called for the virtual table read. In this function, if 
the `values` field in the provided `VirtualTable` struct is empty, the read 
returns an empty relation. However, the `values` field of `VirtualTable` is 
[deprecated](https://github.com/substrait-io/substrait/blob/d430e521f203aec6a4e06731d4bfd68cdf61f443/proto/substrait/algebra.proto#L150)
 and the `expressions` field of `VirtualTable` should be used to specify rows 
of a table; this function returns an empty table prematurely, when 
`expressions` is non-empty.
   
   Returns `EmptyRelation` if `values` is empty:
   
   
![Image](https://github.com/user-attachments/assets/fa6fd9e3-43f3-4b48-b8f5-2528b8fa05bf)
   `expressions` should be supported in addition to the deprecated field 
`values`:
   
   
![Image](https://github.com/user-attachments/assets/9df60b57-8201-45ec-87c4-7452a9d3081f)
   
   ### To Reproduce
   
   1. Build a Substrait plan with expressions in embedded virtual table.
   * Here's a snippet of a Substrait plan in YAML format with a virtual table 
that has expressions but no values.
   
![Image](https://github.com/user-attachments/assets/990d99bb-dfa2-4991-b103-b4783e5ae303)
   3. Convert the Substrait plan to a DataFusion `LogicalPlan` and execute the 
query.
   4. Observe that the result has 0 rows.
   
   ### Expected behavior
   
   `from_read_rel()` should not return an empty relation and there should be 
rows in the outputted table.
   
   ### Additional context
   
   _No response_


-- 
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: github-unsubscr...@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to