Skip to content

Commit

Permalink
fix(interactive): Fix Gremlin Alias Issue in GraphBuilder (#3918)
Browse files Browse the repository at this point in the history
Co-authored-by: BingqingLyu <[email protected]>
  • Loading branch information
shirly121 and BingqingLyu authored Jun 14, 2024
1 parent 674a6aa commit 87054c4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,9 @@ public GraphBuilder as(String alias) {
RelNode top = requireNonNull(peek(), "frame stack is empty");
// skip intermediate operations which make no changes to the row type, i.e.
// filter/limit/dedup...
RelNode parent = null;
while (!top.getInputs().isEmpty() && top.getInput(0).getRowType() == top.getRowType()) {
parent = top;
top = top.getInput(0);
}
if (top instanceof AbstractBindableTableScan
Expand Down Expand Up @@ -1832,6 +1834,10 @@ public GraphBuilder as(String alias) {
aggregate(aggregate.getGroupKey(), ImmutableList.of(aggCall.as(alias)));
}
}
if (parent != null && peek() != top) {
parent.replaceInput(0, build());
push(parent);
}
}
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,16 @@ public void g_V_path_expand_until_age_gt_30_values_age() {
node.explain().trim());
}

@Test
public void g_V_has_label_person_limit_10_as_a() {
RelNode node = eval("g.V().hasLabel('person').limit(10).as('a')");
Assert.assertEquals(
"GraphLogicalProject($f0=[_], isAppend=[false])\n"
+ " GraphLogicalSort(fetch=[10])\n"
+ " GraphLogicalSource(tableConfig=[{isAll=false, tables=[person]}],"
+ " alias=[a], opt=[VERTEX])",
node.explain().trim());

@Test
public void g_V_select_a_b_valueMap() {
RelNode rel =
Expand All @@ -1713,5 +1723,6 @@ public void g_V_select_a_b_valueMap() {
+ " MAP, ([CHAR(2), CHAR(4), CHAR(4), CHAR(12), CHAR(3)], [BIGINT, CHAR(1),"
+ " CHAR(1), DATE, INTEGER]) MAP]) MAP",
rel.getRowType().getFieldList().get(0).getType().toString());

}
}

0 comments on commit 87054c4

Please sign in to comment.