-
Notifications
You must be signed in to change notification settings - Fork 8
handle array columns in Trino handler #201
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
14 commits
Select commit
Hold shift + click to select a range
90c788e
ENG-35650: add support for map type in Trino handler
satish-mittal dae66fb
pinot-servicemanager use 0.6.6
satish-mittal e54a792
use hypertrace-view-generator:0.9.20 for integrationTest
satish-mittal d7fb9c1
use hypertrace-view-generator:0.9.21 for integrationTest
satish-mittal 8f35ae1
fix typo
satish-mittal ef33caf
use hypertrace/hypertrace-view-generator:main in integrationTest
satish-mittal 6374ab7
fix vulnerabilities
satish-mittal 8224d1b
fix vulnerability
satish-mittal 1904836
rename variable
satish-mittal 7dcb200
add support for like and contains_key_like operator
satish-mittal 6f9e949
Merge branch 'main' into trino_func_types
satish-mittal f2b6f9a
handle array columns in Trino handler
satish-mittal dc27836
Merge branch 'main' into trino_func_types
satish-mittal 38cba44
fix vuln
satish-mittal 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -243,37 +243,60 @@ private void handleConversionForArrayColumnExpression( | |
|
||
if (handleConversionForNullOrEmptyArrayLiteral(lhs, operator, builder, value)) return; | ||
|
||
// support only equals and IN operator | ||
// both of them are handled as contains check to align with existing implementation | ||
if (operator.equals("=") | ||
|| operator.equals("IN") | ||
|| operator.equals("!=") | ||
|| operator.equals("NOT IN")) { | ||
// add NOT operator to negate the match condition | ||
if (operator.equals("!=") || operator.equals("NOT IN")) { | ||
// Support only equals and IN operator | ||
if (operator.equals("=") || operator.equals("!=")) { | ||
// Equals (=): CONTAINS(ip_types, 'Bot') | ||
// Not equals (!=): NOT CONTAINS(ip_types, 'Bot') | ||
if (operator.equals("!=")) { | ||
builder.append("NOT "); | ||
} | ||
builder.append("CONTAINS("); | ||
builder.append(lhs); | ||
// overlap operator for array | ||
builder.append(" && "); | ||
builder.append(", "); | ||
if (value.getValueType() == ValueType.STRING) { | ||
builder.append(QUESTION_MARK); | ||
paramsBuilder.addStringParam(value.getString()); | ||
} else { | ||
throw new IllegalArgumentException( | ||
String.format("Unsupported value {%s} for array column", value)); | ||
} | ||
builder.append(")"); | ||
} else if (operator.equals("IN") || operator.equals("NOT IN")) { | ||
// IN: CARDINALITY(ARRAY_INTERSECT(ip_types, ARRAY['Public Proxy', 'Bot'])) > 0 | ||
// NOT IN: CARDINALITY(ARRAY_INTERSECT(ip_types, ARRAY['Public Proxy', 'Bot'])) = 0 | ||
builder.append("CARDINALITY("); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: changes looks fine. For readability, would it make sense to move to a function? |
||
builder.append("ARRAY_INTERSECT("); | ||
builder.append(lhs); | ||
builder.append(", ARRAY["); | ||
switch (value.getValueType()) { | ||
case STRING: | ||
builder.append(QUESTION_MARK); | ||
paramsBuilder.addStringParam(value.getString()); | ||
break; | ||
case STRING_ARRAY: | ||
String delim = ""; | ||
for (String item : value.getStringArrayList()) { | ||
builder.append(delim); | ||
builder.append(QUESTION_MARK); | ||
paramsBuilder.addStringParam(item); | ||
delim = ", "; | ||
} | ||
break; | ||
default: | ||
throw new IllegalArgumentException( | ||
String.format("Unsupported value {%s} for array column", value)); | ||
} | ||
builder.append("]))"); | ||
if (operator.equals("IN")) { | ||
builder.append(" > 0"); | ||
} else { | ||
builder.append(" = 0"); | ||
} | ||
} else { | ||
throw new IllegalArgumentException( | ||
String.format( | ||
"Unsupported operator {%s} for array column with non-empty value", operator)); | ||
} | ||
builder.append("?"); | ||
switch (value.getValueType()) { | ||
case STRING: | ||
paramsBuilder.addStringParam("{" + value.getString() + "}"); | ||
break; | ||
case STRING_ARRAY: | ||
paramsBuilder.addStringParam("{" + String.join(", ", value.getStringArrayList()) + "}"); | ||
break; | ||
default: | ||
throw new IllegalArgumentException( | ||
String.format("Unsupported value {%s} for array column", value)); | ||
} | ||
builder.append(QUESTION_MARK); | ||
} | ||
|
||
private boolean handleConversionForNullOrEmptyArrayLiteral( | ||
|
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.
Nit: changes looks fine. For readability, would it make sense to move to a function?