Repository navigation
Support bi-directional graph traversal command graphlookup - #5113
Conversation
Signed-off-by: Lantao Jin <[email protected]>
…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 <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
|
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 <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
graphlookup
| * | ||
| * <p>Returns: List - array of [row_fields..., depth?] | ||
| */ | ||
| public class GraphLookupBfsFunction extends ImplementorUDF { |
There was a problem hiding this comment.
Could the classes GraphLookupBfsFunction and GraphLookupFunction prune?
| } | ||
| } | ||
|
|
||
| if (++currentLevelDepth > graphLookup.maxDepth) break; |
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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 <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
…rch-project#5113) * succeed to graph lookup single index Signed-off-by: Lantao Jin <[email protected]> * Implement graph lookup RelNode Signed-off-by: Heng Qian <[email protected]> * Refine - remove depth from BFS node Signed-off-by: Heng Qian <[email protected]> * Support bidirectional mode Signed-off-by: Heng Qian <[email protected]> * Support anonymize graph lookup Signed-off-by: Heng Qian <[email protected]> * Fix UT Signed-off-by: Heng Qian <[email protected]> * Add IT Signed-off-by: Heng Qian <[email protected]> * Add limitation for GraphLookup Signed-off-by: Heng Qian <[email protected]> * Simplify GraphLookup param names Signed-off-by: Heng Qian <[email protected]> * Refine IT Signed-off-by: Heng Qian <[email protected]> * Support value of list; Support retrieve circle edges also Signed-off-by: Heng Qian <[email protected]> * Add documentation for graph lookup Signed-off-by: Heng Qian <[email protected]> * Don't include loop edges Signed-off-by: Heng Qian <[email protected]> * Refine code Signed-off-by: Heng Qian <[email protected]> * spotlessApply Signed-off-by: Heng Qian <[email protected]> * Refine code Signed-off-by: Heng Qian <[email protected]> * Filter visited nodes in search query Signed-off-by: Heng Qian <[email protected]> * Fix UT Signed-off-by: Heng Qian <[email protected]> * Add parameter supportArray for handling fields with array values Signed-off-by: Heng Qian <[email protected]> * Remove unused code Signed-off-by: Heng Qian <[email protected]> * Support batch mode Signed-off-by: Heng Qian <[email protected]> * Close lookup table scan Signed-off-by: Heng Qian <[email protected]> * refine code Signed-off-by: Heng Qian <[email protected]> * Add param usePIT Signed-off-by: Heng Qian <[email protected]> --------- Signed-off-by: Lantao Jin <[email protected]> Signed-off-by: Heng Qian <[email protected]> Co-authored-by: Lantao Jin <[email protected]> Signed-off-by: Lantao Jin <[email protected]>
#5138) * Support bi-directional graph traversal command `graphlookup` (#5113) * succeed to graph lookup single index Signed-off-by: Lantao Jin <[email protected]> * Implement graph lookup RelNode Signed-off-by: Heng Qian <[email protected]> * Refine - remove depth from BFS node Signed-off-by: Heng Qian <[email protected]> * Support bidirectional mode Signed-off-by: Heng Qian <[email protected]> * Support anonymize graph lookup Signed-off-by: Heng Qian <[email protected]> * Fix UT Signed-off-by: Heng Qian <[email protected]> * Add IT Signed-off-by: Heng Qian <[email protected]> * Add limitation for GraphLookup Signed-off-by: Heng Qian <[email protected]> * Simplify GraphLookup param names Signed-off-by: Heng Qian <[email protected]> * Refine IT Signed-off-by: Heng Qian <[email protected]> * Support value of list; Support retrieve circle edges also Signed-off-by: Heng Qian <[email protected]> * Add documentation for graph lookup Signed-off-by: Heng Qian <[email protected]> * Don't include loop edges Signed-off-by: Heng Qian <[email protected]> * Refine code Signed-off-by: Heng Qian <[email protected]> * spotlessApply Signed-off-by: Heng Qian <[email protected]> * Refine code Signed-off-by: Heng Qian <[email protected]> * Filter visited nodes in search query Signed-off-by: Heng Qian <[email protected]> * Fix UT Signed-off-by: Heng Qian <[email protected]> * Add parameter supportArray for handling fields with array values Signed-off-by: Heng Qian <[email protected]> * Remove unused code Signed-off-by: Heng Qian <[email protected]> * Support batch mode Signed-off-by: Heng Qian <[email protected]> * Close lookup table scan Signed-off-by: Heng Qian <[email protected]> * refine code Signed-off-by: Heng Qian <[email protected]> * Add param usePIT Signed-off-by: Heng Qian <[email protected]> --------- Signed-off-by: Lantao Jin <[email protected]> Signed-off-by: Heng Qian <[email protected]> Co-authored-by: Lantao Jin <[email protected]> * Struct return array value instead of string Signed-off-by: Heng Qian <[email protected]> * Support filter in GraphLookup Signed-off-by: Heng Qian <[email protected]> * Fix IT Signed-off-by: Heng Qian <[email protected]> * Add experimental tag in doc Signed-off-by: Heng Qian <[email protected]> * Support filter params in graphlookup (#5134) * Struct return array value instead of string Signed-off-by: Heng Qian <[email protected]> * Support filter in GraphLookup Signed-off-by: Heng Qian <[email protected]> * Fix IT Signed-off-by: Heng Qian <[email protected]> * Add experimental tag in doc Signed-off-by: Heng Qian <[email protected]> --------- Signed-off-by: Heng Qian <[email protected]> * Address comments Signed-off-by: Heng Qian <[email protected]> --------- Signed-off-by: Lantao Jin <[email protected]> Signed-off-by: Heng Qian <[email protected]> Co-authored-by: qianheng <[email protected]>
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.