You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "LiaCastaneda (via GitHub)" <gi...@apache.org> on 2026/09/07 10:53:01 UTC

[I] Nested struct field access on lambda parameters is unsupported (SQL and Substrait) [datafusion]

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

   ### Is your feature request related to a problem or challenge?
   
   `e.field` doesn't resolve when `e` is a lambda parameter of struct type, in both the SQL frontend and the Substrait consumer path. Accessing the same nested field on an ordinary struct-typed column works fine in both -- this is specific to lambda-bound variables.
   
   ### To Reproduce
   
   ```
   -- Works: whole lambda parameter, no dotted access. Real field names
   -- (rule_number, rule_action) survive into the output type.
   SELECT array_transform(
     make_array(named_struct('rule_number', 1, 'rule_action', 'allow')),
     e -> e
   );
   
   -- Fails: dotted access into the lambda parameter's own struct fields.
   SELECT array_transform(
     make_array(named_struct('rule_number', 1, 'rule_action', 'allow')),
     e -> e.rule_action
   );
   ```
   
   The second query fails with `Schema error: No field named e.rule_action`. -- even purely in the SQL planner, no Substrait involved.
   
   
   
   ### Describe the solution you'd like
   
   Support referencing a field in the struct type inside a lambda (in both paths)
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### 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-unsubscribe@datafusion.apache.org.apache.org

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


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


Re: [I] Nested struct field access on lambda parameters is unsupported (SQL and Substrait) [datafusion]

Posted by "LiaCastaneda (via GitHub)" <gi...@apache.org>.
LiaCastaneda commented on issue #25017:
URL: https://github.com/apache/datafusion/issues/25017#issuecomment-5600515195

   ok not sure this is super urgent actually, we can use `get_field` and it will work
   ```
   SELECT array_transform(
     make_array(named_struct('rule_number', 1, 'rule_action', 'allow')),
     e -> get_field(e, 'rule_action')
   );
   ```
   


-- 
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-unsubscribe@datafusion.apache.org

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


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


Re: [I] Nested struct field access on lambda parameters is unsupported (SQL and Substrait) [datafusion]

Posted by "LiaCastaneda (via GitHub)" <gi...@apache.org>.
LiaCastaneda commented on issue #25017:
URL: https://github.com/apache/datafusion/issues/25017#issuecomment-5601459873

   the roundtrip (SQL -> substrait -> SQL) for this one will not work though 
   ```
   SET datafusion.sql_parser.dialect = 'DuckDB';   -- needed just to parse `x -> expr` lambda syntax at all
   
   WITH test_data AS (
       SELECT named_struct(
           'label', 'example',
           'items', [
               named_struct('name', 'first', 'value', 2),
               named_struct('name', 'second', 'value', 5)
           ]
       ) AS row_col
   )
   SELECT
       row_col.label,
       array_transform(row_col.items, item -> get_field(item, 'value') * 10) AS scaled_values
   FROM test_data;
   ```


-- 
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-unsubscribe@datafusion.apache.org

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


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