hanyuzheng7 opened a new pull request, #30136:
URL: https://github.com/apache/flink/pull/30136
## What is the purpose of the change
`JSON_EXISTS` accepts a first argument of any type during validation, but
code generation supports only character strings. Any other type fails with a
message that reads like a missing feature, in batch and in streaming mode:
```sql
CREATE TABLE T (r ROW<a INT, b STRING>) WITH ('connector' = 'datagen');
SELECT JSON_EXISTS(r, '$.a') FROM T;
```
```
Unsupported call: JSON_EXISTS(ROW<`a` INT, `b` STRING>, CHAR(3) NOT NULL) If
you think this function should be supported, you can create an issue and start
a discussion for it.
```
With this change, validation fails with:
```
Unsupported type 'ROW<`a` INT, `b` STRING>' for the first argument of
JSON_EXISTS(). Supported types are CHAR, VARCHAR and STRING. Use JSON_STRING()
to convert a value of another type to a JSON string.
```
A query in which the optimizer removes such a call before code generation,
e.g. `SELECT JSON_EXISTS(int_col, '$.a') FROM T WHERE FALSE`, used to run and
now fails validation.
## Brief change log
- Add `SqlJsonExistsFunctionWrapper`, which rejects a first argument that
isn't a character string, as `SqlJsonQueryFunctionWrapper` checks the
`RETURNING` type of `JSON_QUERY`.
- Use it as `FlinkSqlOperatorTable.JSON_EXISTS`.
## Verifying this change
Added cases to `JsonFunctionsITCase`: a ROW and an INT first argument fail
validation, and `JSON_EXISTS(JSON_STRING(f0), '$.a')` returns true.
## 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
- If yes, how is the feature documented? not applicable
--
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]