Skip to content

Commit b2db3bd

Browse files
authored
fix(interactive): fix the bug in missing metadata in PathExpand (#3667)
<!-- Thanks for your contribution! please review https://github.com/alibaba/GraphScope/blob/main/CONTRIBUTING.md before opening an issue. --> ## What do these changes do? <!-- Please give a short brief about these changes. --> As titled. ## Related issue number <!-- Are there any issues opened that will be resolved by merging this change? --> Fixes #3666
1 parent b81e511 commit b2db3bd

10 files changed

+111
-72
lines changed

interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/runtime/proto/GraphRelToProtoConverter.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
import com.alibaba.graphscope.common.config.PegasusConfig;
2121
import com.alibaba.graphscope.common.ir.meta.schema.CommonOptTable;
2222
import com.alibaba.graphscope.common.ir.rel.*;
23-
import com.alibaba.graphscope.common.ir.rel.GraphLogicalAggregate;
24-
import com.alibaba.graphscope.common.ir.rel.GraphLogicalDedupBy;
25-
import com.alibaba.graphscope.common.ir.rel.GraphLogicalProject;
26-
import com.alibaba.graphscope.common.ir.rel.GraphLogicalSort;
27-
import com.alibaba.graphscope.common.ir.rel.GraphShuttle;
2823
import com.alibaba.graphscope.common.ir.rel.graph.*;
2924
import com.alibaba.graphscope.common.ir.rel.graph.match.GraphLogicalMultiMatch;
3025
import com.alibaba.graphscope.common.ir.rel.graph.match.GraphLogicalSingleMatch;
@@ -52,6 +47,7 @@
5247
import org.apache.calcite.rel.logical.LogicalFilter;
5348
import org.apache.calcite.rel.logical.LogicalJoin;
5449
import org.apache.calcite.rel.logical.LogicalUnion;
50+
import org.apache.calcite.rel.type.RelDataType;
5551
import org.apache.calcite.rel.type.RelDataTypeField;
5652
import org.apache.calcite.rex.*;
5753
import org.apache.calcite.sql.SqlKind;
@@ -220,6 +216,7 @@ public RelNode visit(GraphLogicalPathExpand pxd) {
220216
GraphAlgebraPhysical.PathExpand.ExpandBase.Builder expandBaseBuilder =
221217
GraphAlgebraPhysical.PathExpand.ExpandBase.newBuilder();
222218
RelNode fused = pxd.getFused();
219+
RelDataType rowType;
223220
if (fused != null) {
224221
// the case that expand base is fused
225222
if (fused instanceof GraphPhysicalGetV) {
@@ -231,6 +228,7 @@ public RelNode visit(GraphLogicalPathExpand pxd) {
231228
GraphPhysicalExpand fusedExpand = (GraphPhysicalExpand) fusedGetV.getInput();
232229
GraphAlgebraPhysical.EdgeExpand.Builder expand = buildEdgeExpand(fusedExpand);
233230
expandBaseBuilder.setEdgeExpand(expand);
231+
rowType = fusedExpand.getRowType();
234232
} else {
235233
throw new UnsupportedOperationException(
236234
"unsupported fused plan in path expand base: "
@@ -241,6 +239,7 @@ public RelNode visit(GraphLogicalPathExpand pxd) {
241239
GraphPhysicalExpand fusedExpand = (GraphPhysicalExpand) fused;
242240
GraphAlgebraPhysical.EdgeExpand.Builder expand = buildEdgeExpand(fusedExpand);
243241
expandBaseBuilder.setEdgeExpand(expand);
242+
rowType = fusedExpand.getFusedExpand().getRowType();
244243
} else {
245244
throw new UnsupportedOperationException(
246245
"unsupported fused plan in path expand base");
@@ -252,6 +251,7 @@ public RelNode visit(GraphLogicalPathExpand pxd) {
252251
GraphAlgebraPhysical.GetV.Builder getV = buildGetV((GraphLogicalGetV) pxd.getGetV());
253252
expandBaseBuilder.setEdgeExpand(expand);
254253
expandBaseBuilder.setGetV(getV);
254+
rowType = pxd.getExpand().getRowType();
255255
}
256256
pathExpandBuilder.setBase(expandBaseBuilder);
257257
pathExpandBuilder.setPathOpt(Utils.protoPathOpt(pxd.getPathOpt()));
@@ -266,6 +266,7 @@ public RelNode visit(GraphLogicalPathExpand pxd) {
266266
}
267267
oprBuilder.setOpr(
268268
GraphAlgebraPhysical.PhysicalOpr.Operator.newBuilder().setPath(pathExpandBuilder));
269+
oprBuilder.addAllMetaData(Utils.physicalProtoRowType(rowType, isColumnId));
269270
if (isPartitioned) {
270271
addRepartitionToAnother(pxd.getStartAlias().getAliasId());
271272
}
@@ -281,8 +282,11 @@ public RelNode visit(GraphPhysicalExpand physicalExpand) {
281282
GraphAlgebraPhysical.EdgeExpand.Builder edgeExpand = buildEdgeExpand(physicalExpand);
282283
oprBuilder.setOpr(
283284
GraphAlgebraPhysical.PhysicalOpr.Operator.newBuilder().setEdge(edgeExpand));
285+
// Currently we use the row type of ExpandE as the output row type of the fused
286+
// ExpandV, as desired by the engine implementation.
284287
oprBuilder.addAllMetaData(
285-
Utils.physicalProtoRowType(physicalExpand.getRowType(), isColumnId));
288+
Utils.physicalProtoRowType(
289+
physicalExpand.getFusedExpand().getRowType(), isColumnId));
286290
if (isPartitioned) {
287291
addRepartitionToAnother(physicalExpand.getStartAlias().getAliasId());
288292
}

interactive_engine/compiler/src/test/resources/proto/edge_expand_degree_test.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,21 @@
5151
},
5252
"metaData": [{
5353
"type": {
54-
"dataType": "INT64"
54+
"graphType": {
55+
"elementOpt": "EDGE",
56+
"graphDataType": [{
57+
"label": {
58+
"srcLabel": 0,
59+
"dstLabel": 0
60+
},
61+
"props": [{
62+
"propId": {
63+
"name": "weight"
64+
},
65+
"type": "DOUBLE"
66+
}]
67+
}]
68+
}
5569
},
5670
"alias": -1
5771
}]

interactive_engine/compiler/src/test/resources/proto/edge_expand_vertex_filter_test.json

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,17 @@
5151
"metaData": [{
5252
"type": {
5353
"graphType": {
54+
"elementOpt": "EDGE",
5455
"graphDataType": [{
5556
"label": {
57+
"srcLabel": 0,
58+
"dstLabel": 0
5659
},
5760
"props": [{
5861
"propId": {
59-
"name": "id"
60-
},
61-
"type": "INT64"
62-
}, {
63-
"propId": {
64-
"name": "name"
62+
"name": "weight"
6563
},
66-
"type": "STRING"
67-
}, {
68-
"propId": {
69-
"name": "age"
70-
},
71-
"type": "INT32"
64+
"type": "DOUBLE"
7265
}]
7366
}]
7467
}

interactive_engine/compiler/src/test/resources/proto/edge_expand_vertex_test.json

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,22 @@
5252
"metaData": [{
5353
"type": {
5454
"graphType": {
55+
"elementOpt": "EDGE",
5556
"graphDataType": [{
5657
"label": {
58+
"srcLabel": 0,
59+
"dstLabel": 0
5760
},
5861
"props": [{
5962
"propId": {
60-
"name": "id"
61-
},
62-
"type": "INT64"
63-
}, {
64-
"propId": {
65-
"name": "name"
63+
"name": "weight"
6664
},
67-
"type": "STRING"
68-
}, {
69-
"propId": {
70-
"name": "age"
71-
},
72-
"type": "INT32"
65+
"type": "DOUBLE"
7366
}]
7467
}]
7568
}
76-
}
69+
},
70+
"alias": -1
7771
}]
7872
}, {
7973
"opr": {

interactive_engine/compiler/src/test/resources/proto/edge_expand_vertex_with_filters_test.json

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,17 @@
8080
"metaData": [{
8181
"type": {
8282
"graphType": {
83+
"elementOpt": "EDGE",
8384
"graphDataType": [{
8485
"label": {
86+
"srcLabel": 0,
87+
"dstLabel": 0
8588
},
8689
"props": [{
8790
"propId": {
88-
"name": "id"
89-
},
90-
"type": "INT64"
91-
}, {
92-
"propId": {
93-
"name": "name"
91+
"name": "weight"
9492
},
95-
"type": "STRING"
96-
}, {
97-
"propId": {
98-
"name": "age"
99-
},
100-
"type": "INT32"
93+
"type": "DOUBLE"
10194
}]
10295
}]
10396
}

interactive_engine/compiler/src/test/resources/proto/partitioned_edge_expand_degree_test.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,21 @@
5858
},
5959
"metaData": [{
6060
"type": {
61-
"dataType": "INT64"
61+
"graphType": {
62+
"elementOpt": "EDGE",
63+
"graphDataType": [{
64+
"label": {
65+
"srcLabel": 0,
66+
"dstLabel": 0
67+
},
68+
"props": [{
69+
"propId": {
70+
"name": "weight"
71+
},
72+
"type": "DOUBLE"
73+
}]
74+
}]
75+
}
6276
},
6377
"alias": -1
6478
}]

interactive_engine/compiler/src/test/resources/proto/partitioned_edge_expand_vertex_filter_test.json

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,17 @@
5858
"metaData": [{
5959
"type": {
6060
"graphType": {
61+
"elementOpt": "EDGE",
6162
"graphDataType": [{
6263
"label": {
64+
"srcLabel": 0,
65+
"dstLabel": 0
6366
},
6467
"props": [{
6568
"propId": {
66-
"name": "id"
67-
},
68-
"type": "INT64"
69-
}, {
70-
"propId": {
71-
"name": "name"
69+
"name": "weight"
7270
},
73-
"type": "STRING"
74-
}, {
75-
"propId": {
76-
"name": "age"
77-
},
78-
"type": "INT32"
71+
"type": "DOUBLE"
7972
}]
8073
}]
8174
}

interactive_engine/compiler/src/test/resources/proto/partitioned_edge_expand_vertex_test.json

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,22 @@
5959
"metaData": [{
6060
"type": {
6161
"graphType": {
62+
"elementOpt": "EDGE",
6263
"graphDataType": [{
6364
"label": {
65+
"srcLabel": 0,
66+
"dstLabel": 0
6467
},
6568
"props": [{
6669
"propId": {
67-
"name": "id"
68-
},
69-
"type": "INT64"
70-
}, {
71-
"propId": {
72-
"name": "name"
70+
"name": "weight"
7371
},
74-
"type": "STRING"
75-
}, {
76-
"propId": {
77-
"name": "age"
78-
},
79-
"type": "INT32"
72+
"type": "DOUBLE"
8073
}]
8174
}]
8275
}
83-
}
76+
},
77+
"alias": -1
8478
}]
8579
}, {
8680
"opr": {

interactive_engine/compiler/src/test/resources/proto/path_expand_test.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,27 @@
7070
"pathOpt": "SIMPLE",
7171
"resultOpt": "ALL_V"
7272
}
73-
}
73+
},
74+
"metaData": [{
75+
"type": {
76+
"graphType": {
77+
"elementOpt": "EDGE",
78+
"graphDataType": [{
79+
"label": {
80+
"srcLabel": 0,
81+
"dstLabel": 0
82+
},
83+
"props": [{
84+
"propId": {
85+
"name": "weight"
86+
},
87+
"type": "DOUBLE"
88+
}]
89+
}]
90+
}
91+
},
92+
"alias": -1
93+
}]
7494
}, {
7595
"opr": {
7696
"sink": {

interactive_engine/compiler/src/test/resources/proto/path_fused_expand_test.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,27 @@
5757
"pathOpt": "SIMPLE",
5858
"resultOpt": "ALL_V"
5959
}
60-
}
60+
},
61+
"metaData": [{
62+
"type": {
63+
"graphType": {
64+
"elementOpt": "EDGE",
65+
"graphDataType": [{
66+
"label": {
67+
"srcLabel": 0,
68+
"dstLabel": 0
69+
},
70+
"props": [{
71+
"propId": {
72+
"name": "weight"
73+
},
74+
"type": "DOUBLE"
75+
}]
76+
}]
77+
}
78+
},
79+
"alias": -1
80+
}]
6181
}, {
6282
"opr": {
6383
"sink": {

0 commit comments

Comments
 (0)