# How can I have a PPL Query transforming/reducing nested fields

**URL:** <https://forum.opensearch.org/t/how-can-i-have-a-ppl-query-transforming-reducing-nested-fields/28359>\
**Category:** OpenSearch\
**Created:** [October 21, 2026, 6:06pm UTC](https://forum.opensearch.org/t/how-can-i-have-a-ppl-query-transforming-reducing-nested-fields/28359 "2026-10-21T18:06:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DGT](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@DGT](https://forum.opensearch.org/u/DGT)\
**Post date:** [October 21, 2026, 6:06pm UTC](https://forum.opensearch.org/t/how-can-i-have-a-ppl-query-transforming-reducing-nested-fields/28359/1 "2026-10-21T18:06:27Z")

</div>

Hello,

I am facing an issue when attempting to work with nested fields in a PPL query, as such fields seem to be detected as “undefined” type.

Is there anything to be changed on index mapping and/or ppl logic to interact with such nested fields ?

**Versions** : OpenSearch 3.7

**Describe the issue** : Nested fields appear as “undefined” type in the below query, and they cannot be involved in any kind of transformation/reduction

**Configuration** :

Index mapping is defined as below

> {  
> “my\_index”: {  
> “mappings”: {  
> “properties”: {  
> “description”: {  
> “type”: “text”  
> },  
> “id”: {  
> “type”: “keyword”  
> },  
> “name”: {  
> “type”: “text”  
> },  
> “report\_columns”: {  
> “type”: “nested”,  
> “properties”: {  
> “label”: {  
> “type”: “keyword”  
> },  
> “name”: {  
> “type”: “keyword”  
> },  
> “position”: {  
> “type”: “integer”  
> }  
> }  
> }  
> }  
> },  
> “settings”: { \<…\> }  
> }  
> }

Sample document is

> {  
> “\_index”: “my\_index”,  
> “\_id”: “sample identifier”,  
> “\_source”: {  
> “id”: “sample identifier”,  
> “report\_columns”: [  
> {  
> “name”: “doctype”,  
> “label”: “Document Type”,  
> “position”: 1  
> },  
> {  
> “name”: “amount”,  
> “label”: “Amount”,  
> “position”: 2  
> }  
> ],  
> “name”: “sample name”,  
> “description”: “sample description”  
> }  
> }

**PPL Query that reports nested entries as “undefined”**

Query

> source = my\_index  
> | eval result = transform(report\_columns, x → typeof(x))  
> | fields id, name, result

Result

| id | name | result |
| --- | --- | --- |
| sample identifier | sample name | [“UNDEFINED”, “UNDEFINED”] |

**PPL Query that fails interacting with nested entries**

Query

> source = my\_index  
> | eval result = transform(report\_columns, x → concat(x.name, ’ as `', x.label, '`'))  
> | fields id, name, result

Error message

ExecutePPLQuery received unexpected status code 500: Cannot create lambda function, Cannot create lambda function

Expected Result

| id | name | result |
| --- | --- | --- |
| sample identifier | sample name | [“docType as `Document Type`”, “amount as `Amount`”] |

**Relevant Logs or Screenshots** : N/A

Kind regards  
Denis

---

<div class="post-metadata">

**Author:** ![eywora](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/eywora/32/10378_2.png) [@eywora](https://forum.opensearch.org/u/eywora)\
**Post date:** [October 22, 2026, 6:47am UTC](https://forum.opensearch.org/t/how-can-i-have-a-ppl-query-transforming-reducing-nested-fields/28359/2 "2026-10-22T06:47:47Z")

</div>

Hi Denis,

the UNDEFINED type suggests the lambda in transform doesn’t get a typed struct for the elements of a nested field, which is why x.name can’t be resolved and the lambda fails. The array functions seem to be written for arrays of primitives (or arrays built with array()), not for nested documents. A workaround that should work on 3.7 is to unpack the nested field into rows with expand, build the string per row and collect it again:

```

source = my\_index

| expand report\_columns

| sort id, report\_columns.position

| eval col = concat(report\_columns.name, ’ as ', report\_columns.label)

| stats list(col) as result by id, name

```

I haven’t run this exact query on 3.7, so treat it as a starting point. If transform should support nested fields directly, it’s worth opening an issue in the opensearch-project/sql repo with your example, since it’s a clean repro.

Ahmed

---

<div class="post-metadata">

**Author:** ![DGT](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@DGT](https://forum.opensearch.org/u/DGT)\
**Post date:** [October 22, 2026, 8:17am UTC](https://forum.opensearch.org/t/how-can-i-have-a-ppl-query-transforming-reducing-nested-fields/28359/3 "2026-10-22T08:17:40Z")

</div>

Hello Ahmed,

I already experimented a strategy based on expand/stats (switching from expand to mvexpand)

But unfortunately this led me to a drawback / edge case in case report\_columns is empty/null for a given document in my\_index : such documents no longer appear in the results

**Example** : i have the below documents

Document 1

> {  
> “\_index”: “my\_index”,  
> “\_id”: “identifier1”,  
> “\_source”: {  
> “id”: “identifier1”,  
> “report\_columns”: [  
> {  
> “name”: “doctype”,  
> “label”: “Document Type”,  
> “position”: 1  
> },  
> {  
> “name”: “amount”,  
> “label”: “Amount”,  
> “position”: 2  
> }  
> ],  
> “name”: “name1”,  
> “description”: “description1”  
> }  
> }

Document 2

> {  
> “\_index”: “my\_index”,  
> “\_id”: “identifier2”,  
> “\_source”: {  
> “id”: “identifier2”,  
> “report\_columns”: [],  
> “name”: “name2”,  
> “description”: “description2”  
> }  
> }

Document 3

> {  
> “\_index”: “my\_index”,  
> “\_id”: “identifier3”,  
> “\_source”: {  
> “id”: “identifier3”,  
> “name”: “name3”,  
> “description”: “description3”  
> }  
> }

**Result**  
(documents standing for ids identifier2 and identifier3 missing due to the empty/null value they have for report\_columns.

| id | name | col |
| --- | --- | --- |
| identifier1 | name1 | [“doctype as `Document Type`”, “amount as `Amount`”] |

Would there be a hint to ensure that such rows/documents are not silently ignored when leverating mvexpand/stats ?

Kind regards  
Denis

---

<div class="post-metadata">

**Author:** ![eywora](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/eywora/32/10378_2.png) [@eywora](https://forum.opensearch.org/u/eywora)\
**Post date:** [October 22, 2026, 9:32am UTC](https://forum.opensearch.org/t/how-can-i-have-a-ppl-query-transforming-reducing-nested-fields/28359/4 "2026-10-22T09:32:06Z")

</div>

Hi Denis,

that’s the difference between the two commands. mvexpand drops rows where the array is empty, but expand keeps them: the 3.7 docs say that for an empty array “the row is retained with the expanded field set to null”. So with expand instead of mvexpand, identifier2 should come through with an empty or null result. The docs only mention empty arrays, though, not documents where the field is missing completely like identifier3.

If identifier3 still disappears, you can add those documents back with append:

```

source = my\_index

| expand report\_columns

| sort id, report\_columns.position

| eval col = concat(report\_columns.name, ’ as ', report\_columns.label)

| stats list(col) as result by id, name

| append [source = my\_index | where isnull(report\_columns) | fields id, name]

```

Check that the append doesn’t produce duplicates for identifier2, since an empty array may also count as null there. If the transform on nested fields turns out to be a gap rather than a usage issue, it’s worth raising in the opensearch-project/sql repo, since your three documents are a clean repro.

Ahmed

---

<div class="post-metadata">

**Author:** ![DGT](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@DGT](https://forum.opensearch.org/u/DGT)\
**Post date:** [October 22, 2026, 11:03am UTC](https://forum.opensearch.org/t/how-can-i-have-a-ppl-query-transforming-reducing-nested-fields/28359/5 "2026-10-22T11:03:03Z")

</div>

Hi Ahmed,

I was missing the **append** trick, which helps pertaining rows with a null array, meaning I can work with this workaround for the time being, thanks !

As you suggested, I logged an issue against opensearch-project/sql repository

> <https://github.com/opensearch-project/sql/issues/5904>
>
> \## Query Information
> \*\*PPL Command/Query:\*\*
> \`\`\`ppl
> source = my\_index
> | eval resu…lt = transform(report\_columns, x -\> concat(x.name, ’ as ', x.label, ''))
> | fields id, name, result
> \`\`\`
> \*\*Expected Result:\*\*
> 
> id | name | result
> \-- | -- | --
> identifier1 | name1 | \[“docType as Document Type”, “amount as Amount”\]
> identifier2 | name2 | \[\]
> identifier3 | name3 | 
> 
> \*\*Actual Result:\*\*
> 
> ExecutePPLQuery received unexpected status code 500: Cannot create lambda function, Cannot create lambda function
> 
> \## Dataset Information
> \*\*Dataset/Schema Type\*\*
> \- \[\] OpenTelemetry (OTEL)
> \- \[\] Simple Schema for Observability (SS4O)
> \- \[\] Open Cybersecurity Schema Framework (OCSF)
> \- \[x\] Custom (details below)
> 
> \*\*Index Mapping\*\*
> \`\`\`json
> {
> "mappings": {
> "properties": {
> "description": { "type": "text" },
> "id": { "type": "keyword" },
> "name": { "type": "text" },
> "report\_columns": {
> "type": "nested",
> "properties": {
> "label": { "type": "keyword" },
> "name": { "type": "keyword" },
> "position": { "type": "integer" }
> }
> }
> }
> }
> }
> \`\`\`
> \*\*Sample Data\*\*
> 
> Document 1
> 
> \`\`\`json
> {
> "\_index": "my\_index",
> "\_id": "identifier1",
> "\_source": {
> "id": "identifier1",
> "report\_columns": \[
> {
> "name": "doctype",
> "label": "Document Type",
> "position": 1
> },
> {
> "name": "amount",
> "label": "Amount",
> "position": 2
> }
> \],
> "name": "name1",
> "description": "description1"
> }
> }
> \`\`\`
> Document 2
> 
> \`\`\`json
> {
> "\_index": "my\_index",
> "\_id": "identifier2",
> "\_source": {
> "id": "identifier2",
> "report\_columns": \[\],
> "name": "name2",
> "description": "description2"
> }
> }
> \`\`\`
> 
> Document 3
> 
> \`\`\`json
> {
> "\_index": "my\_index",
> "\_id": "identifier3",
> "\_source": {
> "id": "identifier3",
> "name": "name3",
> "description": "description3"
> }
> }
> \`\`\`
> 
> \## Bug Description
> \*\*Issue Summary:\*\*
> I need to properly leverage nested fields in lambdas involved in transform, reduce, etc. when working with arrays of objects
> 
> \*\*Steps to Reproduce:\*\*
> Run the provided ppl query against index/documents provided as examples
> 
> Additionally, i noticed that the below ppl query identifies all nested fields as type "UNDEFINED"
> 
> \`\`\`ppl
> source = my\_index
> | eval result = transform(report\_columns, x -\> typeof(x))
> | fields id, name, result
> \`\`\`
> 
> \*\*Impact:\*\*
> I am not able to fully leverage nested fields.
> Workardound consists in introducing \`expand\` or \`mvexpand\`
> 
> \## Environment Information
> \*\*OpenSearch Version:\*\*
> OpenSearch 3.7
> 
> \*\*Additional Details:\*\*
> N/A
> 
> \## Screenshots
> N/A

Kind regards,  
Denis
