flink
flink copied to clipboard
[FLINK-32264][table] Add-built-in FIELD-function.
What is the purpose of the change
This is an implementation of FIELD The FIELD function returns the position of a value in a list of values (val...). The list support mixed data type.
Brief change log
FIELD for Table API and SQL
Syntax:
FIELD(value, val...)
Arguments: value: The value to find in the list. val... : The list of values that is to be searched.
Returns: If value is not found in the list of values (val...), the FIELD function will return 0. If value is NULL, the FIELD function will return 0. If list of values is NULL or EMPTY, return 0.
Examples:
SELECT FIELD('b', 'a', 'b', 'c', 'd', 'e', 'f');
Result: 2
SELECT FIELD(ARRAY[1, 2, 3], 1, 'b', 'c', ARRAY[1, 2, 3], 'e', 'f');
Result: 4
SELECT FIELD(15, 10, 20, 15, 40);
Result: 3
SELECT FIELD('c', 2.1, 'b');
Result: 0
SELECT FIELD('g', '');
Result: 0
SELECT FIELD(null, 'a', 2, 'c');
Result: 0
SELECT FIELD('a', null);
Result: 0
See also: MySQL:https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_field
Verifying this change
- This change added tests in CollectionFunctionsITCase.
Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (yes / no)
- The public API, i.e., is any changed class annotated with
@Public(Evolving)
: (yes / no) - The serializers: (yes / no / don't know)
- The runtime per-record code paths (performance sensitive): (yes / no / don't know)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
- The S3 file system connector: (yes / no / don't know)
Documentation
- Does this pull request introduce a new feature? (yes / no)
- If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
CI report:
- 0d58c43b10aeabd467db5a72bd5af8936b8ed967 UNKNOWN
- 02679b4e8bd689d9cc5cbc3a2c341155ac44bd76 Azure: SUCCESS
Bot commands
The @flinkbot bot supports the following commands:-
@flinkbot run azure
re-run the last Azure build
@flinkbot run azure