-
Notifications
You must be signed in to change notification settings - Fork 181
Support bi-directional graph traversal command graphlookup
#5113
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
Conversation
Signed-off-by: Lantao Jin <ltjin@amazon.com>
…graphlookup # Conflicts: # core/src/main/java/org/opensearch/sql/analysis/Analyzer.java # core/src/main/java/org/opensearch/sql/ast/AbstractNodeVisitor.java # core/src/main/java/org/opensearch/sql/calcite/CalciteRelNodeVisitor.java # ppl/src/main/antlr/OpenSearchPPLParser.g4
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
|
Change the target branch to |
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
graphlookup
| * | ||
| * <p>Returns: List - array of [row_fields..., depth?] | ||
| */ | ||
| public class GraphLookupBfsFunction extends ImplementorUDF { |
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.
Could the classes GraphLookupBfsFunction and GraphLookupFunction prune?
| } | ||
| } | ||
|
|
||
| if (++currentLevelDepth > graphLookup.maxDepth) break; |
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.
Seems it processes one additional level. For example maxDepth=2, it processes 3 levels total instead of stopping at level 2:
1st level done, then check (++0 > 2 ❎), continue;
2nd level done, then check (++1 > 2 ❎), continue;
3rd level done, then check (++ 2 > 2 ✅), stop
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.
That's by design. It starts from 0 hop which stands for direct connection. It means we can set maxDepth=0. You can refer to mongdb's definition about this param, it should be a non-negative integer
| if (graphLookup.depthField != null) { | ||
| Object[] rowWithDepth = new Object[rowArray.length + 1]; | ||
| System.arraycopy(rowArray, 0, rowWithDepth, 0, rowArray.length); | ||
| rowWithDepth[rowArray.length] = currentLevelDepth; |
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.
currentLevelDepth represents the depth of SOURCE nodes being queried, not the TARGET nodes being added to results. Target nodes should be at depth currentLevelDepth + 1?
Tests with depthField use default maxDepth=0, which only processes one iteration, so all results correctly show depth=0. Tests with maxDepth > 0 don't verify depth values.
| } | ||
|
|
||
| @Override | ||
| public Object current() { |
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.
Lacks ResourceMonitor health checks during BFS traversal. Need to add periodic health check monitor.isHealthy() in moveNext() and performBfs().
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 monitor is inner both scan for source table and lookup table. Since our all operators actually share the same jvm and monitor. It will be triggered in each iteration inner scan of source or lookup table.
|
|
||
| query = QueryBuilders.boolQuery().should(query).should(backQuery); | ||
| } | ||
| CalciteEnumerableIndexScan newScan = (CalciteEnumerableIndexScan) this.lookupScan.copy(); |
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 code creates new scan instance but never close it? can you debug to check if this instance be closed expectedly.
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Description
[Describe what this change achieves]
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
Check List
--signoffor-s.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.