apache / apache/beam

[Bug]: UNNEST ARRAY with a nested ROW (described below)

Open
#26,911 0 comments 0 reactions 0 assignees View on GitHub
awaiting triage bug java P2
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
1d 20h
Merged PRs (30d)
196

Description

### What happened?

In Beam SQL shell (tested with calcite, DirectRunner, DataFlow, v2.47.0 and latest main on linux):
```
CREATE EXTERNAL TABLE test_tmp(
`ref` VARCHAR,
`commits` ARRAY
>>
)
TYPE text
LOCATION 'tests/array_with_nested_rows_limitation.jsonl'
TBLPROPERTIES '{"format":"json", "deadLetterFile":"tests/dead"}';
SELECT
test_tmp.`ref` AS branch_name,
commit_item.`id` AS commit_hash,
commit_item.`author`.`name` AS author_name
FROM test_tmp
CROSS JOIN UNNEST(test_tmp.commits) AS commit_item;
```
gives
```
Row expected 4 fields (Field{name=ref, description=, type=STRING, options={{}}}, Field{name=commits, description=, type=ARRAY> NOT NULL>, options={{}}}, Field{name=id, description=, type=STRING, options={{}}}, Field{name=author, description=, type=ROW, options={{}}}). initialized with 5 fields.
```
Which essentially leaves no way to explode all elements of an array through SQL. Accessing a single element works as expected.
Also related issue - when doing `SELECT *` from a table that contains at least one nested row - a very similar exception is thrown.

### Issue Priority

Priority: 1 (data loss / total loss of function)

### Issue Components

- [ ] Component: Python SDK
- [X] Component: Java SDK
- [ ] Component: Go SDK
- [ ] Component: Typescript SDK
- [ ] Component: IO connector
- [ ] Component: Beam examples
- [ ] Component: Beam playground
- [ ] Component: Beam katas
- [ ] Component: Website
- [ ] Component: Spark Runner
- [ ] Component: Flink Runner
- [ ] Component: Samza Runner
- [ ] Component: Twister2 Runner
- [ ] Component: Hazelcast Jet Runner
- [ ] Component: Google Cloud Dataflow Runner

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.