generated from amazon-archives/__template_Custom
-
Notifications
You must be signed in to change notification settings - Fork 181
Implement Parameter Validation for PPL functions on Calcite #3626
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
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
c26ff17
Support type checker For PPL functions
qianheng-aws e639dcf
Implement type checkers for UDF
yuancu a7f252f
Implement composite type checker
yuancu a887e2d
Merge origin/main into type-checker
yuancu e1e4deb
Define type checkers for UDFs
yuancu fe0385c
Display expected signatures when type checking fails & support type c…
yuancu f3f94ce
Add ITs for UDF type checking
yuancu 5733337
Merge remote-tracking branch 'origin/main' into type-checker
yuancu f059c44
Fix: correct CONV's operand types
yuancu d288f38
Fix test parse IT
yuancu a11381b
Remove unused code in UserDefinedFunctionUtils
yuancu 4c66bbb
Refactor: improve ITs, javadocs, type checkers
yuancu 138b67b
Improve javadoc for PPLTypeChecker
yuancu 783cdb1
Return false at validation for mismatched operand count with expectat…
yuancu 8bba4b7
Merge remote-tracking branch 'origin/main' into type-checker
yuancu f6107b1
Add type checker for cidrmatch
yuancu 882cb88
Correct cidrmatch type checker
yuancu d34857f
Fix compile error in CalcitePPLAbstractTest.java
yuancu 77d49a1
Experiment: support type checking for built-in operators by accessing…
yuancu 1bf526d
Check composition type for only calcite's built-in operators
yuancu 714a39d
Support parameter validation for comparabale operators
yuancu 2376ca6
Support parameter validation for coalesce (by reusing comparable type…
yuancu 281f755
Support parameter validation for substring
yuancu 45f1566
Support parameter validation for if
yuancu 638c3d6
Support parameter validation for nullif, isempty, isblank
yuancu df71074
Merge remote-tracking branch 'origin/main' into type-checker
yuancu 139d858
Align types in type check error information to actual types in PPL
yuancu 85e0b31
Display PPL types when failing to resolve a function
yuancu 63c94a4
Merge origin/main into type-checker
yuancu 18921bd
Create type checker for geoip function
yuancu e3a491d
Merge origin/main into type-checker
yuancu d9669ab
Define type checker for grok and item operators
yuancu 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
64 changes: 64 additions & 0 deletions
64
core/src/main/java/org/opensearch/sql/calcite/utils/PPLOperandTypes.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * | ||
| * * Copyright OpenSearch Contributors | ||
| * * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| */ | ||
|
|
||
| package org.opensearch.sql.calcite.utils; | ||
|
|
||
| import org.apache.calcite.sql.type.CompositeOperandTypeChecker; | ||
| import org.apache.calcite.sql.type.FamilyOperandTypeChecker; | ||
| import org.apache.calcite.sql.type.OperandTypes; | ||
| import org.apache.calcite.sql.type.SqlTypeFamily; | ||
| import org.opensearch.sql.expression.function.UDFOperandMetadata; | ||
|
|
||
| /** | ||
| * This class contains common operand types for PPL functions. They are created by either wrapping a | ||
| * {@link FamilyOperandTypeChecker} or a {@link CompositeOperandTypeChecker} with a {@link | ||
| * UDFOperandMetadata}. | ||
| */ | ||
| public class PPLOperandTypes { | ||
| // This class is not meant to be instantiated. | ||
| private PPLOperandTypes() {} | ||
|
|
||
| public static final UDFOperandMetadata NONE = UDFOperandMetadata.wrap(OperandTypes.family()); | ||
| public static final UDFOperandMetadata OPTIONAL_INTEGER = | ||
| UDFOperandMetadata.wrap( | ||
| (CompositeOperandTypeChecker) OperandTypes.INTEGER.or(OperandTypes.family())); | ||
| public static final UDFOperandMetadata STRING = | ||
| UDFOperandMetadata.wrap((FamilyOperandTypeChecker) OperandTypes.STRING); | ||
| public static final UDFOperandMetadata INTEGER = | ||
| UDFOperandMetadata.wrap((FamilyOperandTypeChecker) OperandTypes.INTEGER); | ||
| public static final UDFOperandMetadata NUMERIC = | ||
| UDFOperandMetadata.wrap((FamilyOperandTypeChecker) OperandTypes.NUMERIC); | ||
| public static final UDFOperandMetadata INTEGER_INTEGER = | ||
| UDFOperandMetadata.wrap((FamilyOperandTypeChecker) OperandTypes.INTEGER_INTEGER); | ||
| public static final UDFOperandMetadata STRING_STRING = | ||
| UDFOperandMetadata.wrap(OperandTypes.STRING_STRING); | ||
| public static final UDFOperandMetadata NUMERIC_NUMERIC = | ||
| UDFOperandMetadata.wrap((FamilyOperandTypeChecker) OperandTypes.NUMERIC_NUMERIC); | ||
| public static final UDFOperandMetadata NUMERIC_NUMERIC_NUMERIC = | ||
| UDFOperandMetadata.wrap( | ||
| OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC)); | ||
|
|
||
| public static final UDFOperandMetadata DATETIME_OR_STRING = | ||
| UDFOperandMetadata.wrap( | ||
| (CompositeOperandTypeChecker) OperandTypes.DATETIME.or(OperandTypes.STRING)); | ||
| public static final UDFOperandMetadata DATETIME_DATETIME = | ||
| UDFOperandMetadata.wrap(OperandTypes.family(SqlTypeFamily.DATETIME, SqlTypeFamily.DATETIME)); | ||
| public static final UDFOperandMetadata DATETIME_OR_STRING_DATETIME_OR_STRING = | ||
| UDFOperandMetadata.wrap( | ||
| (CompositeOperandTypeChecker) | ||
| OperandTypes.STRING_STRING | ||
| .or(OperandTypes.family(SqlTypeFamily.DATETIME, SqlTypeFamily.DATETIME)) | ||
| .or(OperandTypes.family(SqlTypeFamily.DATETIME, SqlTypeFamily.STRING)) | ||
| .or(OperandTypes.family(SqlTypeFamily.STRING, SqlTypeFamily.DATETIME))); | ||
| public static final UDFOperandMetadata TIME_OR_TIMESTAMP_OR_STRING = | ||
| UDFOperandMetadata.wrap( | ||
| (CompositeOperandTypeChecker) | ||
| OperandTypes.STRING.or(OperandTypes.TIME).or(OperandTypes.TIMESTAMP)); | ||
| public static final UDFOperandMetadata DATE_OR_TIMESTAMP_OR_STRING = | ||
| UDFOperandMetadata.wrap( | ||
| (CompositeOperandTypeChecker) OperandTypes.DATE_OR_TIMESTAMP.or(OperandTypes.STRING)); | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.