-
Notifications
You must be signed in to change notification settings - Fork 10
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
Array filtering support (Part #4): Postgres array filter impl. #191
Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
e8f06db
Basics of array operator support
suresh-prakash cd439f9
ArrayFilterExpression support (Part #1)
suresh-prakash 44e6690
Simplify Mongo execution by removing redundant filters
suresh-prakash a348ca8
Merge remote-tracking branch 'origin' into array_filter_support
suresh-prakash c6ba6cd
Split the Array Expression into 2 (for leaf and internal)
suresh-prakash 157f26e
Comment fixes and renaming
suresh-prakash 37058ad
Further refactoring
suresh-prakash 0960315
Minor refactoring
suresh-prakash cc4347c
Refactor to take-in the wrapping LHS parser
suresh-prakash 369daa4
Minor fixes
suresh-prakash 7ac51bd
MongoDB implementation of array filter with integration test
suresh-prakash 0021c9a
Functionality working for MongoDB
suresh-prakash c074d5c
Revert "Functionality working for MongoDB"
suresh-prakash ad3c865
Revert "MongoDB implementation of array filter with integration test"
suresh-prakash 3ffa433
MongoDB implementation of array filter with integration test
suresh-prakash dba24d4
Functionality working for MongoDB
suresh-prakash 6c8a7c5
Refactoring to unify the implementation
suresh-prakash 879c87e
Refactor
suresh-prakash ca0c7c0
Merge branch 'array_filter_support' into array_filter_mongo_impl
suresh-prakash 73f7125
Refactored cleanly
suresh-prakash 7d273f5
Postgres relational filter refactoring
suresh-prakash d157442
Refactor
suresh-prakash 79c44e2
Merge branch 'array_filter_mongo_impl' into postgres_filter_parser_re…
suresh-prakash 4fabba5
Merge remote-tracking branch 'origin' into array_filter_mongo_impl
suresh-prakash 6defee8
Merge remote-tracking branch 'origin' into postgres_filter_parser_ref…
suresh-prakash 57a10f8
Merge branch 'array_filter_mongo_impl' into postgres_filter_parser_re…
suresh-prakash c374531
Partial changes
suresh-prakash 912e0c9
Postgres Array Filter implementation
suresh-prakash c0e20d0
Fixed for additional test
suresh-prakash bfde2f4
Merge branch 'main' into postgres_filter_parser_refactoring
suresh-prakash 19cbb1a
Addressed review comments
suresh-prakash 9bbabbb
Merge branch 'postgres_filter_parser_refactoring' into postgres_array…
suresh-prakash 809c758
Fixed test failures
suresh-prakash 7187d95
Fixed code comment
suresh-prakash e80c2ab
Merge remote-tracking branch 'origin' into postgres_array_filter_impl
suresh-prakash e63860b
Update document-store/src/main/java/org/hypertrace/core/documentstore…
suresh-prakash 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 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 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 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
33 changes: 33 additions & 0 deletions
33
...store/postgres/query/v1/vistors/PostgresArrayRelationalWrappingFilterVisitorProvider.java
This file contains 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,33 @@ | ||
package org.hypertrace.core.documentstore.postgres.query.v1.vistors; | ||
|
||
import lombok.AllArgsConstructor; | ||
import org.hypertrace.core.documentstore.expression.type.SelectTypeExpression; | ||
import org.hypertrace.core.documentstore.postgres.query.v1.PostgresQueryParser; | ||
|
||
@AllArgsConstructor | ||
public class PostgresArrayRelationalWrappingFilterVisitorProvider | ||
implements PostgresWrappingFilterVisitorProvider { | ||
|
||
private PostgresQueryParser postgresQueryParser; | ||
private String arraySource; | ||
private String alias; | ||
|
||
@Override | ||
public PostgresSelectTypeExpressionVisitor getForRelational( | ||
final PostgresSelectTypeExpressionVisitor baseVisitor, final SelectTypeExpression rhs) { | ||
// Override the base visitor, | ||
// pick the LHS field name (elements.inner), | ||
// replace it with alias (inner), and | ||
// optionally trim double quotes (TRIM('"' FROM inner::text)) | ||
return new PostgresIdentifierTrimmingExpressionVisitor( | ||
new PostgresIdentifierReplacingExpressionVisitor( | ||
new PostgresIdentifierExpressionVisitor(postgresQueryParser), arraySource, alias), | ||
rhs); | ||
} | ||
|
||
@Override | ||
public PostgresSelectTypeExpressionVisitor getForNonRelational( | ||
PostgresSelectTypeExpressionVisitor baseVisitor) { | ||
return getForRelational(baseVisitor, null); | ||
Check warning on line 31 in document-store/src/main/java/org/hypertrace/core/documentstore/postgres/query/v1/vistors/PostgresArrayRelationalWrappingFilterVisitorProvider.java
|
||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...ntstore/postgres/query/v1/vistors/PostgresDocumentArrayWrappingFilterVisitorProvider.java
This file contains 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,31 @@ | ||
package org.hypertrace.core.documentstore.postgres.query.v1.vistors; | ||
|
||
import lombok.AllArgsConstructor; | ||
import org.hypertrace.core.documentstore.expression.type.SelectTypeExpression; | ||
import org.hypertrace.core.documentstore.postgres.query.v1.PostgresQueryParser; | ||
|
||
@AllArgsConstructor | ||
public class PostgresDocumentArrayWrappingFilterVisitorProvider | ||
implements PostgresWrappingFilterVisitorProvider { | ||
|
||
private PostgresQueryParser postgresQueryParser; | ||
private String alias; | ||
|
||
@Override | ||
public PostgresSelectTypeExpressionVisitor getForRelational( | ||
final PostgresSelectTypeExpressionVisitor baseVisitor, final SelectTypeExpression rhs) { | ||
// Override the existing parser, | ||
// parse the field name (meta.num_moons), | ||
// get data accessor expression prefixed with alias (planets->'meta'->>'num_moons'), and | ||
// cast according to the value type (CAST (planets->'meta'->>'num_moons' AS NUMERIC) > ?) | ||
return new PostgresRelationalIdentifierAccessingExpressionVisitor( | ||
new PostgresIdentifierExpressionVisitor(postgresQueryParser), alias, rhs); | ||
} | ||
|
||
@Override | ||
public PostgresSelectTypeExpressionVisitor getForNonRelational( | ||
final PostgresSelectTypeExpressionVisitor baseVisitor) { | ||
// Any LHS field name (elements) is to be prefixed with current alias (inner) | ||
return new PostgresIdentifierAccessingExpressionVisitor(baseVisitor, alias); | ||
} | ||
} |
This file contains 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.
If there are more operators, we should move the code for each operator to its dedicated function for readability? For instance, moving code of any operator to
getFilterExpressionForAnyOperator()
here.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.
Sure