-
Notifications
You must be signed in to change notification settings - Fork 193
Default empty array() return type to ARRAY<VARCHAR> #5421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ahkcs
merged 3 commits into
opensearch-project:feature/mustang-ppl-integration
from
ahkcs:feature/array-empty-default-varchar
May 8, 2026
+96
−0
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is CAST(ARRAY[] to VARCHAR[])? Add an UT to cover this assumption.
Question, Is it limitation of Substrait, becuase it does not supoort UNKNOW?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refer PostgreSQL, it does not allow construct empty ARRAY[].
https://www.postgresql.org/docs/current/sql-expressions.html#SQL-SYNTAX-ARRAY-CONSTRUCTORS
But in PPL, we allow create emtpy array(). So which means we implict covert to varchar[] in future, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes — semantically equivalent to
CAST(ARRAY[] AS VARCHAR[]). The fallback path adds an empty-typed-array case Calcite/Postgres handle via explicit cast, but PPL surface allows barearray()so we do it implicitly.Yes, Substrait limitation — Substrait's
Typeproto has no encoding forUNKNOWN(or Calcite'sNULLSqlTypeName as an element type). When isthmus'TypeConverter.toSubstraitwalks anARRAY<UNKNOWN>it can't produce a valid wire type and throwsUnsupportedOperationException: Unable to convert the type UNKNOWN. The Calcite-engine local executor is more lenient because it never serializes the type — it just iterates the emptyList<Object>and never reads the element type.UT added in aa82704 —
testReturnTypeForEmptyCallIsVarcharArrayandtestReturnTypeForAllNullOperandsIsVarcharArraycover both fallback paths (empty operand list and typeless-NULL operand).testReturnTypeForIntegerOperandPreservesTypeis the regression guard that confirms concrete element types pass through unchanged.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right — that's the trade-off. Postgres requires the explicit cast (
SELECT ARRAY[]::integer[]); PPL doesn't have that surface today, so any caller writing barearray()would otherwise hit an analytics-engine-side error. The implicit VARCHAR default keeps the bare form working, and concrete-element calls (array(1, 2),array('a')) keep their original element type —testReturnTypeForIntegerOperandPreservesTypein aa82704 is the regression guard for that.Long-term we could expose a PPL
cast(array() as <T>[])syntax that mirrors Postgres and remove the implicit default, but that's a separate language-surface change.