Skip to content

Commit

Permalink
fix(interactive): fix bugs in physical plan converter in GOpt (#4109)
Browse files Browse the repository at this point in the history
  • Loading branch information
BingqingLyu authored Aug 13, 2024
1 parent 0f427ce commit 3b49437
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
Expand Down Expand Up @@ -396,6 +396,8 @@ public RelNode visit(LogicalFilter filter) {
Map<Integer, Set<GraphNameOrId>> 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()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -738,7 +739,7 @@ public static Set<GraphNameOrId> 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<Integer, Set<GraphNameOrId>> tagColumns) {
List<RelDataTypeField> fieldTypes = inputDataType.getFieldList();
Expand All @@ -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<Integer> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"tables": [{
"id": 0
}],
"columns": [{
"name": "weight"
}],
"sampleRatio": 1.0
}
}
Expand Down

0 comments on commit 3b49437

Please sign in to comment.