generated from amazon-archives/__template_Custom
-
Notifications
You must be signed in to change notification settings - Fork 180
Use Calcite's validation system for type checking & coercion #4892
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
Open
yuancu
wants to merge
84
commits into
opensearch-project:main
Choose a base branch
from
yuancu:issues/4636
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
84 commits
Select commit
Hold shift + click to select a range
1e04df1
WIP: try introducing sql validator without disabling the legacy type …
yuancu 229cb1d
Override deriveType in validator to allow type checking on UDTs
yuancu b529a35
Add special handling for datetime coercion
yuancu 34b2435
Override coerceOperandType and castTo methods to apply casting to udf…
yuancu e6e01c8
Fix interval semantic mismatch between sql and ppl
yuancu 15e0bef
Fix quarter interval bug in calcite (counte-react)
yuancu a1f2f42
Comment out function overloadings to make basic functions work
yuancu 7f999df
Remove unused validator operators
yuancu 39e208a
Update sargFromJson method in ExtendedRelJson
yuancu 55e8486
Prepend following rules for datetime comparisons: (date, time) -> tim…
yuancu dc44f8c
Directly delegate type checking to sql type checkers (1292/1599 | 125…
yuancu a4dfd3f
Enable IP comparison (1332/1559 | 1409/1915)
yuancu 9deca8b
Fix expected type checking for agg functions (1287/1599 | 1423/1914)
yuancu 11c33ba
Define operand types for json functions
yuancu a4b0d72
Define operand types and return type inferences for array functions (…
yuancu c237041
Add hive sql library operators for array_slice function, which is use…
yuancu 51c556f
Define overrides for atan function to allow conditional sql call rewr…
yuancu dc3bc41
Update operand types for percentile approx to allow with addtional ty…
yuancu 09f45e7
Correct span function type routing (allow any)
yuancu a30fa3a
Define operand type for DISTINCT_COUNT_APPROX
yuancu a588864
Unconditionally rewrite COUNT() to COUNT(*) in sql level to allow typ…
yuancu 4cd7570
Define operand types for EnhancedCoalesce, ScalarMin & Max; remove Sq…
yuancu dcb3b8f
Correct type checkers for mvappend; fix regexp lookup; correct isempt…
yuancu c230765
Initiate a new RelToSqlConverter every time as it is stateful (1769/2…
yuancu 8200cf7
Override add for string concat and number addition (1773/2018)
yuancu 4abc31e
Switch sql dialect to opensearch spark sql dialect (1772/2018)
yuancu 0269692
Align null order in collation (1783/2018)
yuancu 0118313
Skip validations for bin-on-timestamps (1799/2027)
yuancu 4adfa98
Do not remove sort in subqueries when converting sql to rel (1820/2027)
yuancu 4838c4c
Trim unused fields after when converting sql back to rel (1857/2027)
yuancu 545ed04
Pass on join type of logical correlate to lateral join (1858/2027)
yuancu 1aea9e3
Support semi and anti join in the converted SQL (1860/2027)
yuancu 9f369b0
Disable insertion of json_type operator (1864/2027)
yuancu 9bffce8
Rewrite IN / NOT IN with tuple inputs to row(...tuple) to conform to …
yuancu 96801c6
Update exception type of testSpanByImplicitTimestamp
yuancu c3bde24
Update PplTypeCoercionRule to allow CAST(IP as STRING)
yuancu 15f17b3
Fix float literal by inserting compulsory cast
yuancu 9b9c07a
Extend spark dialect to support cast null to IP (1880/2028)
yuancu 443d81e
Support sql-udt conversion of composite types (1881/2028)
yuancu e1bab21
Add geoip of string override because the udt type is erased during va…
yuancu 6a7feae
Skip validation when grouping by two cases (1885/2028)
yuancu 2d36650
Embed collations into window for streamstats (1910/2054, before rebas…
yuancu 23e611a
Skip validation when logical values is used to create empty rows (191…
yuancu 6286e90
Remove EnhancedCoalesceFunction in favor of built-in Coalesce functio…
yuancu 0736444
Fix ITs that are affected by allowing implicit coercion from number t…
yuancu 53a4118
Return original logical plan when get error message 'Aggregate expres…
yuancu 7f52976
Reorganize class structures and refactor for readability
yuancu c4de0e4
Remove validation logics from PPLFuncImpTable
yuancu 0667fa7
Remove unused classes (1917/2055)
yuancu 485c038
Merge remote-tracking branch 'origin/main' into issues/4636 (1929/2069)
yuancu d19ba53
Update the type checker of transform function to allow arbitrary addi…
yuancu 330a4e5
Tolerant group by window function (returning original logical plan)
yuancu f5fda25
Ignore patterns IT that are to be fixed in 4968
yuancu 657cc6a
Allow binary arithmetic operation between string and numerics
yuancu b030f41
Define SqlKind for DIVIDE and MOD UDF for coercion purpose
yuancu 8caa594
Disable nullary call to not confuse with field reference
yuancu 975d21c
Use SAFE_CAST instead of CAST to tolerant malformatted numbers
yuancu bc38f9f
Enable identifier expansion to ensure that casted args in agg functio…
yuancu 502dbb0
Handle least restrictive for UDTs
yuancu 34985c7
Update testBetweenWithIncompatibleTypes
yuancu c660a69
Fix or skip yaml tests
yuancu d9b1453
Pass on exception for bin-on-timestamp exception
yuancu 90b6309
Fix doctest
yuancu ea06ab0
Fix unit tests
yuancu e548ad2
Merge branch '4636-fix-ut' into issues/4636
yuancu 94c7f33
Merge branch '4636-fix-yaml' into issues/4636
yuancu bab48d7
Remove interface PPLTypeChecker
yuancu 6a30697
Pass on bucket_nullable flag to sql node and back to rel node (1929/2…
yuancu 0be7cb4
Fix append and multisearch ITs (1932/2066)
yuancu 38e12c6
Fix unit tests broken by passed-on hints
yuancu 0990db1
Fix calcite, calcite no push down, and v2 ppl explain ITs
yuancu d0195cb
Merge remote-tracking branch 'origin/main' into issues/4636
yuancu 9f6dcd7
Update clickbench plans
yuancu d455d35
Fix dedupe explain ITs
yuancu a2d1955
Fix clickbench q41
yuancu 4a98c3a
Fix explain dedup expr complex1
yuancu aff8541
Remove unused CalciteFuncSignature interface
yuancu 229ddb7
Remove type checkers from operator registration because all type chec…
yuancu e6b80e5
Make getValiadtor thread-safe & improve type checking for JsonSet
yuancu cb78ea7
Deprecate interface UDFOperandMetadata.wrapUDT
yuancu 69a2d01
Merge remote-tracking branch 'origin/main' into issues/4636
yuancu d722baf
Fix explain ITs after merging main
yuancu d513e17
Merge remote-tracking branch 'origin/main' into issues/4636
yuancu ff91bdc
Update plans after merging
yuancu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
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
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
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.
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.
🧩 Analysis chain
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 403
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 11109
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 6457
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 3384
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 14929
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 8498
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 123
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 15090
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 103
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 10796
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 1995
🏁 Script executed:
Repository: opensearch-project/sql
Length of output: 558
Address resource leak: Close the statement after validator creation.
The underlying
Statementresource created byconnection.createStatement()is not being closed. AlthoughCalciteServerStatementitself doesn't implementAutoCloseable, it wraps a JDBCStatementthat does hold resources requiring proper cleanup.The statement is only needed to extract the prepare context via
statement.createPrepareContext(). Since it's not stored or reused, close it immediately after validator initialization:Also check
CalciteToolsHelper.withPrepare()for the same pattern—it creates a statement at line 137 that should be closed afterOpenSearchPrepareImpl().perform()completes.The double-checked locking implementation with
volatileis correct.🤖 Prompt for AI Agents