From 3b4943769fe00dfa74dfa89ae08321150178e6b5 Mon Sep 17 00:00:00 2001 From: BingqingLyu Date: Tue, 13 Aug 2024 13:21:38 +0800 Subject: [PATCH] fix(interactive): fix bugs in physical plan converter in GOpt (#4109) --- .../proto/GraphRelToProtoConverter.java | 4 +++- .../common/ir/runtime/proto/Utils.java | 21 ++++++++++++------- .../test/resources/proto/scan_edge_test.json | 3 +++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/runtime/proto/GraphRelToProtoConverter.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/runtime/proto/GraphRelToProtoConverter.java index c2835eee2274..69184c613934 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/runtime/proto/GraphRelToProtoConverter.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/runtime/proto/GraphRelToProtoConverter.java @@ -121,7 +121,7 @@ public RelNode visit(GraphLogicalSource source) { queryParamsBuilder, Utils.extractColumnsFromRelDataType(source.getRowType(), isColumnId)); } - scanBuilder.setParams(buildQueryParams(source)); + scanBuilder.setParams(queryParamsBuilder); if (source.getAliasId() != AliasInference.DEFAULT_ID) { scanBuilder.setAlias(Utils.asAliasId(source.getAliasId())); } @@ -396,6 +396,8 @@ public RelNode visit(LogicalFilter filter) { Map> tagColumns = Utils.extractTagColumnsFromRexNodes(List.of(filter.getCondition())); if (preCacheEdgeProps) { + // Currently, we've already precache edge properties and path properties, so we + // need to remove them. So as the follows. Utils.removeEdgeProperties( com.alibaba.graphscope.common.ir.tools.Utils.getOutputType( filter.getInput()), diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/runtime/proto/Utils.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/runtime/proto/Utils.java index 9ed2b40b1f36..86a354cd2e0f 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/runtime/proto/Utils.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/runtime/proto/Utils.java @@ -22,6 +22,7 @@ import com.alibaba.graphscope.common.ir.tools.config.GraphOpt; import com.alibaba.graphscope.common.ir.type.GraphLabelType; import com.alibaba.graphscope.common.ir.type.GraphNameOrId; +import com.alibaba.graphscope.common.ir.type.GraphPathType; import com.alibaba.graphscope.common.ir.type.GraphProperty; import com.alibaba.graphscope.common.ir.type.GraphSchemaType; import com.alibaba.graphscope.gaia.proto.*; @@ -738,7 +739,7 @@ public static Set extractColumnsFromRelDataType( return columns; } - // remove edge properties from columns by checking if the tags refers to edge type + // remove properties from columns by checking if the tags refers to edge type or path type public static void removeEdgeProperties( RelDataType inputDataType, Map> tagColumns) { List fieldTypes = inputDataType.getFieldList(); @@ -750,19 +751,25 @@ public static void removeEdgeProperties( && GraphOpt.Source.EDGE.equals( ((GraphSchemaType) headFieldType.getType()).getScanOpt())) { tags.remove(AliasInference.DEFAULT_ID); + } else if (headFieldType.getType() instanceof GraphPathType) { + tags.remove(AliasInference.DEFAULT_ID); } } + if (tags.isEmpty()) { return; } - // then, process other tags by checking if they are of edge type + // then, process other tags by checking if they are of edge type or path type List removeKeys = new ArrayList<>(); for (RelDataTypeField fieldType : fieldTypes) { - if (tags.contains(fieldType.getIndex()) - && fieldType.getType() instanceof GraphSchemaType - && GraphOpt.Source.EDGE.equals( - ((GraphSchemaType) fieldType.getType()).getScanOpt())) { - removeKeys.add(fieldType.getIndex()); + if (tags.contains(fieldType.getIndex())) { + if (fieldType.getType() instanceof GraphSchemaType + && GraphOpt.Source.EDGE.equals( + ((GraphSchemaType) fieldType.getType()).getScanOpt())) { + removeKeys.add(fieldType.getIndex()); + } else if (fieldType.getType() instanceof GraphPathType) { + removeKeys.add(fieldType.getIndex()); + } } } tagColumns.keySet().removeAll(removeKeys); diff --git a/interactive_engine/compiler/src/test/resources/proto/scan_edge_test.json b/interactive_engine/compiler/src/test/resources/proto/scan_edge_test.json index cd01cb223be5..0211c4994efc 100644 --- a/interactive_engine/compiler/src/test/resources/proto/scan_edge_test.json +++ b/interactive_engine/compiler/src/test/resources/proto/scan_edge_test.json @@ -8,6 +8,9 @@ "tables": [{ "id": 0 }], + "columns": [{ + "name": "weight" + }], "sampleRatio": 1.0 } }