[ZEPPELIN-6244] Handle Collection as defaultValue in GUI.select() #4973
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[MINOR] Handle Collection as defaultValue in GUI.select()
What is this PR for?
This PR improves the
GUI.select()
method to properly handle Collection objects passed as defaultValue. When a Collection is provided, the method now extracts the first element as the actual default value instead of using the Collection object itself.What type of PR is it?
Improvement
What is the Jira issue?
N/A (Minor improvement)
How should this be tested?
./mvnw test -pl zeppelin-interpreter -Dtest=GUITest
testSelectWithCollectionDefault()
passes["2"]
is passed as defaultValue"2"
as the default value (not the Collection object)Questions:
Description
Problem
Currently, when using
GUI.select()
with a Collection as the defaultValue parameter, the entire Collection object is used as the default value. This can cause issues since the select form expects a single value, not a Collection.Solution
Added logic to check if the defaultValue is a Collection (but not a String, since String implements CharSequence which is a Collection-like interface). If it is:
Code Changes
Test Coverage
Added
testSelectWithCollectionDefault()
test that verifies:"2"
is properly converted to default value"2"
"2"
This change improves the API's flexibility and prevents potential issues when Collections are inadvertently passed as default values.