fornaix opened a new pull request #18679:
URL: https://github.com/apache/flink/pull/18679
## What is the purpose of the change
Suppose we have a map field that needs to be expanded.
```sql
CREATE TABLE t (
id INT,
map_field MAP<STRING, INT>
) WITH (
-- ...
)
SELECT id, k, v FROM t, unnest(map_field) as A(k, v)
```
We will get the following runtime exception:
```
Caused by: java.lang.ClassCastException:
org.apache.flink.table.data.binary.BinaryStringData cannot be cast to
java.lang.Integer
at
org.apache.flink.table.data.GenericRowData.getInt(GenericRowData.java:149)
at
org.apache.flink.table.data.utils.JoinedRowData.getInt(JoinedRowData.java:149)
at
org.apache.flink.table.data.RowData.lambda$createFieldGetter$245ca7d1$6(RowData.java:245)
at
org.apache.flink.table.data.RowData.lambda$createFieldGetter$25774257$1(RowData.java:296)
at
org.apache.flink.table.runtime.typeutils.RowDataSerializer.copyRowData(RowDataSerializer.java:170)
at
org.apache.flink.table.runtime.typeutils.RowDataSerializer.copy(RowDataSerializer.java:131)
at
org.apache.flink.table.runtime.typeutils.RowDataSerializer.copy(RowDataSerializer.java:48)
at
org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.pushToOperator(CopyingChainingOutput.java:80)
at
org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:57)
at
org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:29)
at
org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:56)
at
org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:29)
at
org.apache.flink.table.runtime.util.StreamRecordCollector.collect(StreamRecordCollector.java:44)
at
org.apache.flink.table.runtime.collector.TableFunctionCollector.outputResult(TableFunctionCollector.java:68)
at StreamExecCorrelate$10$TableFunctionCollector$4.collect(Unknown
Source)
at
org.apache.flink.table.runtime.collector.WrappingCollector.outputResult(WrappingCollector.java:39)
at
StreamExecCorrelate$10$TableFunctionResultConverterCollector$8.collect(Unknown
Source)
at
org.apache.flink.table.functions.TableFunction.collect(TableFunction.java:197)
at
org.apache.flink.table.runtime.functions.SqlUnnestUtils$MapUnnestTableFunction.eval(SqlUnnestUtils.java:169)
at StreamExecCorrelate$10.processElement(Unknown Source)
at
org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.pushToOperator(CopyingChainingOutput.java:82)
at
org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:57)
at
org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:29)
at
org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:56)
at
org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:29)
```
This PR is to fix it.
## Brief change log
- Fix the incorrect value getter in map unnest table function
## Verifying this change
This change added tests and can be verified as follows:
```shell
mvn test -Dtest=UnnestTest,LogicalUnnestRuleTest,UnnestITCase
-DfailIfNoTests=false -pl
flink-table/flink-table-runtime,flink-table/flink-table-planner
```
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (no)
- The public API, i.e., is any changed class annotated with
`@Public(Evolving)`: (no)
- The serializers: (no)
- The runtime per-record code paths (performance sensitive): (no)
- Anything that affects deployment or recovery: JobManager (and its
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
- The S3 file system connector: (no)
## Documentation
- Does this pull request introduce a new feature? (no)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]