-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Arrays should be indexable from the end too (#3004)
* Fixes #2974 Arrays should be indexable from the end too
- Loading branch information
1 parent
6dd39b9
commit a166075
Showing
4 changed files
with
109 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
ksql-functional-tests/src/test/resources/query-validation-tests/arrayindex.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"comments": [ | ||
"Arrays should be indexable from the end too", | ||
"https://github.com/confluentinc/ksql/issues/2974" | ||
], | ||
"tests": [ | ||
|
||
{ | ||
"name": "select the first element of an Array", | ||
"statements": [ | ||
"CREATE STREAM test (colors ARRAY<STRING>) WITH (kafka_topic='test_topic', value_format='JSON');", | ||
"CREATE STREAM OUTPUT AS SELECT colors[0] as C FROM test;" | ||
], | ||
"inputs": [ | ||
{"topic": "test_topic", "value": {"colors": ["Red", "Green"]}}, | ||
{"topic": "test_topic", "value": {"colors": ["Black"]}}, | ||
{"topic": "test_topic", "value": {"colors": [null, "Yellow", "Pink"]}}, | ||
{"topic": "test_topic", "value": {"colors": []}} | ||
], | ||
"outputs": [ | ||
{"topic": "OUTPUT", "value": {"C": "Red"}}, | ||
{"topic": "OUTPUT", "value": {"C": "Black"}}, | ||
{"topic": "OUTPUT", "value": {"C": null}}, | ||
{"topic": "OUTPUT", "value": {"C": null}} | ||
] | ||
}, | ||
{ | ||
"name": "select the last element of an Array (-1)", | ||
"statements": [ | ||
"CREATE STREAM test (colors ARRAY<STRING>) WITH (kafka_topic='test_topic', value_format='JSON');", | ||
"CREATE STREAM OUTPUT AS SELECT colors[-1] as C FROM test;" | ||
], | ||
"inputs": [ | ||
{"topic": "test_topic", "value": {"colors": ["Red", "Green"]}}, | ||
{"topic": "test_topic", "value": {"colors": ["Black"]}}, | ||
{"topic": "test_topic", "value": {"colors": ["Pink", "Yellow", "Pink"]}}, | ||
{"topic": "test_topic", "value": {"colors": ["White", "Pink"]}}, | ||
{"topic": "test_topic", "value": {"colors": ["Pink", null]}}, | ||
{"topic": "test_topic", "value": {"colors": []}} | ||
], | ||
"outputs": [ | ||
{"topic": "OUTPUT", "value": {"C": "Green"}}, | ||
{"topic": "OUTPUT", "value": {"C": "Black"}}, | ||
{"topic": "OUTPUT", "value": {"C": "Pink"}}, | ||
{"topic": "OUTPUT", "value": {"C": "Pink"}}, | ||
{"topic": "OUTPUT", "value": {"C": null}}, | ||
{"topic": "OUTPUT", "value": {"C": null}} | ||
] | ||
} | ||
] | ||
} |