Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(interactive): Fix Bugs of Type Inference in Collect(labels(n)) #4398

Merged
merged 1 commit into from
Jan 2, 2025
Merged
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 @@ -296,15 +296,14 @@ public static final Common.DataType protoBasicDataType(RelDataType basicType) {
case MULTISET:
case ARRAY:
RelDataType elementType = basicType.getComponentType();
switch (elementType.getSqlTypeName()) {
case INTEGER:
Common.DataType dataType = protoBasicDataType(elementType);
switch (dataType) {
case INT32:
return Common.DataType.INT32_ARRAY;
case BIGINT:
case INT64:
return Common.DataType.INT64_ARRAY;
case CHAR:
case STRING:
return Common.DataType.STRING_ARRAY;
case DECIMAL:
case FLOAT:
case DOUBLE:
return Common.DataType.DOUBLE_ARRAY;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@
import com.alibaba.graphscope.common.ir.tools.GraphBuilder;
import com.alibaba.graphscope.common.ir.tools.GraphStdOperatorTable;
import com.alibaba.graphscope.common.ir.tools.LogicalPlan;
import com.alibaba.graphscope.common.ir.tools.config.ExpandConfig;
import com.alibaba.graphscope.common.ir.tools.config.GetVConfig;
import com.alibaba.graphscope.common.ir.tools.config.GraphOpt;
import com.alibaba.graphscope.common.ir.tools.config.LabelConfig;
import com.alibaba.graphscope.common.ir.tools.config.PathExpandConfig;
import com.alibaba.graphscope.common.ir.tools.config.SourceConfig;
import com.alibaba.graphscope.common.ir.tools.config.*;
import com.alibaba.graphscope.common.utils.FileUtils;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -1237,6 +1232,24 @@ public void intersect_test_02() throws Exception {
}
}

@Test
public void collect_labels_test() {
Configs configs = getMockCBOConfig();
GraphRelOptimizer optimizer = new GraphRelOptimizer(configs);
IrMeta irMeta = getMockCBOMeta(optimizer);
GraphBuilder builder = Utils.mockGraphBuilder(optimizer, irMeta);
RelNode before =
com.alibaba.graphscope.cypher.antlr4.Utils.eval(
"Match (n:PERSON) Return collect(labels(n));", builder)
.build();
RelNode after = optimizer.optimize(before, new GraphIOProcessor(builder, irMeta));
PhysicalBuilder protoBuilder =
new GraphRelProtoPhysicalBuilder(configs, irMeta, new LogicalPlan(after));
Assert.assertEquals(
FileUtils.readJsonFromResource("proto/collect_labels.json"),
protoBuilder.build().explain().trim());
}

private Configs getMockCBOConfig() {
return new Configs(
ImmutableMap.of(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"plan": [{
"opr": {
"scan": {
"alias": 0,
"params": {
"tables": [{
"id": 1
}],
"sampleRatio": 1.0
}
}
},
"metaData": [{
"type": {
"graphType": {
"graphDataType": [{
"label": {
"label": 1
},
"props": [{
"propId": {
"name": "id"
},
"type": "INT64"
}, {
"propId": {
"name": "firstName"
},
"type": "STRING"
}, {
"propId": {
"name": "lastName"
},
"type": "STRING"
}, {
"propId": {
"name": "gender"
},
"type": "STRING"
}, {
"propId": {
"name": "birthday"
},
"type": "INT64"
}, {
"propId": {
"name": "creationDate"
},
"type": "DATE32"
}, {
"propId": {
"name": "locationIP"
},
"type": "STRING"
}, {
"propId": {
"name": "browserUsed"
},
"type": "STRING"
}]
}]
}
}
}]
}, {
"opr": {
"groupBy": {
"functions": [{
"vars": [{
"tag": {
"id": 0
},
"property": {
"label": {
}
},
"nodeType": {
"dataType": "INT32"
}
}],
"aggregate": "TO_LIST",
"alias": 1
}]
}
},
"metaData": [{
"type": {
"dataType": "INT32_ARRAY"
},
"alias": 1
}]
}, {
"opr": {
"sink": {
"tags": [{
"tag": 1
}],
"sinkTarget": {
"sinkDefault": {
}
}
}
}
}]
}
Loading