Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
/**
* AST node for graphLookup command. Performs BFS graph traversal on a lookup table.
*
* <p>Example: source=employees | graphLookup employees fromField=manager toField=name maxDepth=3
* depthField=level direction=uni as hierarchy
* <p>Example: source=employees | graphLookup employees startWith=manager connectFromField=manager
* connectToField=name maxDepth=3 depthField=level direction=uni as hierarchy
*/
@Getter
@Setter
Expand All @@ -46,13 +46,13 @@ public enum Direction {
private final UnresolvedPlan fromTable;

/** Field in sourceTable to start with. */
private final Field startField;
private final Field startWith;

/** Field in fromTable that represents the outgoing edge. */
private final Field fromField;
private final Field connectFromField;

/** Field in input/fromTable to match against for traversal. */
private final Field toField;
private final Field connectToField;

/** Output field name for collected traversal results. */
private final Field as;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2589,9 +2589,9 @@ public RelNode visitGraphLookup(GraphLookup node, CalcitePlanContext context) {
RelNode sourceTable = builder.build();

// 2. Extract parameters
String startFieldName = node.getStartField().getField().toString();
String fromFieldName = node.getFromField().getField().toString();
String toFieldName = node.getToField().getField().toString();
String startWithName = node.getStartWith().getField().toString();
String connectFromFieldName = node.getConnectFromField().getField().toString();
String connectToFieldName = node.getConnectToField().getField().toString();
String outputFieldName = node.getAs().getField().toString();
String depthFieldName = node.getDepthFieldName();
boolean bidirectional = node.getDirection() == Direction.BI;
Expand Down Expand Up @@ -2621,9 +2621,9 @@ public RelNode visitGraphLookup(GraphLookup node, CalcitePlanContext context) {
LogicalGraphLookup.create(
sourceTable,
lookupTable,
startFieldName,
fromFieldName,
toFieldName,
startWithName,
connectFromFieldName,
connectToFieldName,
outputFieldName,
depthFieldName,
maxDepthValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
public abstract class GraphLookup extends BiRel {

// TODO: use RexInputRef instead of String for there fields
protected final String startField; // Field in source table (start entities)
protected final String fromField; // Field in lookup table (edge source)
protected final String toField; // Field in lookup table (edge target)
protected final String startWith; // Field in source table (start entities)
protected final String connectFromField; // Field in lookup table (edge source)
protected final String connectToField; // Field in lookup table (edge target)
protected final String outputField; // Name of output array field
@Nullable protected final String depthField; // Name of output array field

Expand All @@ -63,9 +63,9 @@ public abstract class GraphLookup extends BiRel {
* @param traitSet Trait set
* @param source Source table RelNode
* @param lookup Lookup table RelNode
* @param startField Field name for start entities
* @param fromField Field name for outgoing edges
* @param toField Field name for incoming edges
* @param startWith Field name for start entities
* @param connectFromField Field name for outgoing edges
* @param connectToField Field name for incoming edges
* @param outputField Name of the output array field
* @param depthField Name of the depth field
* @param maxDepth Maximum traversal depth (-1 for unlimited)
Expand All @@ -81,9 +81,9 @@ protected GraphLookup(
RelTraitSet traitSet,
RelNode source,
RelNode lookup,
String startField,
String fromField,
String toField,
String startWith,
String connectFromField,
String connectToField,
String outputField,
@Nullable String depthField,
int maxDepth,
Expand All @@ -93,9 +93,9 @@ protected GraphLookup(
boolean usePIT,
@Nullable RexNode filter) {
super(cluster, traitSet, source, lookup);
this.startField = startField;
this.fromField = fromField;
this.toField = toField;
this.startWith = startWith;
this.connectFromField = connectFromField;
this.connectToField = connectToField;
this.outputField = outputField;
this.depthField = depthField;
this.maxDepth = maxDepth;
Expand Down Expand Up @@ -130,7 +130,7 @@ protected RelDataType deriveRowType() {
RelDataType sourceRowType = getSource().getRowType();
RelDataType sourceArrayType =
getCluster().getTypeFactory().createArrayType(sourceRowType, -1);
builder.add(startField, sourceArrayType);
builder.add(startWith, sourceArrayType);

// Second field: aggregated lookup rows as array
RelDataType lookupRowType = getLookup().getRowType();
Expand Down Expand Up @@ -178,8 +178,8 @@ public double estimateRowCount(RelMetadataQuery mq) {
@Override
public RelWriter explainTerms(RelWriter pw) {
return super.explainTerms(pw)
.item("fromField", fromField)
.item("toField", toField)
.item("connectFromField", connectFromField)
.item("connectToField", connectToField)
.item("outputField", outputField)
.item("depthField", depthField)
.item("maxDepth", maxDepth)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public class LogicalGraphLookup extends GraphLookup {
* @param traitSet Trait set
* @param source Source table RelNode
* @param lookup Lookup table RelNode
* @param startField Field name for start entities
* @param fromField Field name for outgoing edges
* @param toField Field name for incoming edges
* @param startWith Field name for start entities
* @param connectFromField Field name for outgoing edges
* @param connectToField Field name for incoming edges
* @param outputField Name of the output array field
* @param depthField Name of the depth field
* @param maxDepth Maximum traversal depth (-1 for unlimited)
Expand All @@ -45,9 +45,9 @@ protected LogicalGraphLookup(
RelTraitSet traitSet,
RelNode source,
RelNode lookup,
String startField,
String fromField,
String toField,
String startWith,
String connectFromField,
String connectToField,
String outputField,
@Nullable String depthField,
int maxDepth,
Expand All @@ -61,9 +61,9 @@ protected LogicalGraphLookup(
traitSet,
source,
lookup,
startField,
fromField,
toField,
startWith,
connectFromField,
connectToField,
outputField,
depthField,
maxDepth,
Expand All @@ -79,9 +79,9 @@ protected LogicalGraphLookup(
*
* @param source Source table RelNode
* @param lookup Lookup table RelNode
* @param startField Field name for start entities
* @param fromField Field name for outgoing edges
* @param toField Field name for incoming edges
* @param startWith Field name for start entities
* @param connectFromField Field name for outgoing edges
* @param connectToField Field name for incoming edges
* @param outputField Name of the output array field
* @param depthField Named of the output depth field
* @param maxDepth Maximum traversal depth (-1 for unlimited)
Expand All @@ -95,9 +95,9 @@ protected LogicalGraphLookup(
public static LogicalGraphLookup create(
RelNode source,
RelNode lookup,
String startField,
String fromField,
String toField,
String startWith,
String connectFromField,
String connectToField,
String outputField,
@Nullable String depthField,
int maxDepth,
Expand All @@ -113,9 +113,9 @@ public static LogicalGraphLookup create(
traitSet,
source,
lookup,
startField,
fromField,
toField,
startWith,
connectFromField,
connectToField,
outputField,
depthField,
maxDepth,
Expand All @@ -133,9 +133,9 @@ public RelNode copy(RelTraitSet traitSet, List<RelNode> inputs) {
traitSet,
inputs.get(0),
inputs.get(1),
startField,
fromField,
toField,
startWith,
connectFromField,
connectToField,
outputField,
depthField,
maxDepth,
Expand Down
Loading
Loading