[
https://issues.apache.org/jira/browse/ARROW-18265?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17637308#comment-17637308
]
Weston Pace commented on ARROW-18265:
-------------------------------------
Hmm, I am not sure I understand. I think `field_ref(INTEGER)` and
`field_ref(STRING)` have always done very different things.
{noformat}
field(3) # Grab the 4th top-level field in the bound schema
field('x', 3) # Illegal, all args must be string if repeating
field('x', '3') # Grab the field named "x" in the current schema and then grab
the field named "3"
field('x[3]') # Grab the 3rd item in the (list-type) array named "x"
field('x["3"]') # Grab the child array named "x" in the (struct-type) array
named "x".
field(3, 3) # Not implemented [but could be], grab the 4th child field
# of the 4th top-level (struct-type) field in the bound schema
{noformat}
{quote}
Mentioning this because you used field_ref(0) / field_ref("item") example as
one option in ARROW-17820 how to reference the child field (for expresssion you
want to apply an element-wise kernel on the child array of a ListArray).
{quote}
I think you are referring to this:
{quote}
Perhaps the "map function" for List<T> could be an expression bound to a schema
of "{item: T}" (e.g. so you could do field_ref(0) or field_ref("item")).
{quote}
I would expect it to look something like:
{noformat}
>>> full_schema = pa.schema([pa.field('myStruct', pa.struct([pa.field('myList',
>>> pa.int32())]))])
>>> full_schema
myStruct: struct<myList: int32>
child 0, myList: int32
>>> selectMyList = field('myStruct', 'myList')
# This would also work in a theoretical world where we supported multi-integer
refs
# selectMyList = field(0, 0)
# There are two expressions here. The first expression, field('myStruct',
'myList') is
# bound to full_schema and would select the list array
#
# The second expression pc.field(0) is bound to pa.schema([pa.field('item',
pa.int32())])
# and selects the 0-th field in the schema which is the int32 field.
>>> pc.applyMap(selectMyList, pc.field(0) * 2)
{noformat}
> [C++] Allow FieldPath to work with ListElement
> ----------------------------------------------
>
> Key: ARROW-18265
> URL: https://issues.apache.org/jira/browse/ARROW-18265
> Project: Apache Arrow
> Issue Type: Improvement
> Components: C++
> Reporter: Miles Granger
> Assignee: Miles Granger
> Priority: Major
> Labels: pull-request-available
> Fix For: 11.0.0
>
> Time Spent: 1h 40m
> Remaining Estimate: 0h
>
> {{FieldRef::FromDotPath}} can parse a single list element field. ie.
> {{{}'path.to.list[0]`{}}}but does not work in practice. Failing with:
> _struct_field: cannot subscript field of type list<....>_
> Being able to add a slice or multiple list elements is not within the scope
> of this issue.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)