Skip to content
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
13 changes: 12 additions & 1 deletion flex/engines/graph_db/runtime/common/rt_any.cc
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,19 @@ void sink_vertex(const GraphReadInterface& graph, const VertexRecord& vertex,
results::Vertex* v) {
v->mutable_label()->set_id(vertex.label_);
v->set_id(encode_unique_vertex_id(vertex.label_, vertex.vid_));
// TODO: add properties
const auto& names = graph.schema().get_vertex_property_names(vertex.label_);
// Add primary keys first, since primary keys are also the properties of a
// vertex
auto& primary_key = graph.schema().get_vertex_primary_key(vertex.label_);
if (primary_key.size() > 1) {
LOG(ERROR) << "Currently only support single primary key";
}
auto pk_name = std::get<1>(primary_key[0]);
auto pk_prop = v->add_properties();
pk_prop->mutable_key()->set_name(pk_name);
sink_any(graph.GetVertexId(vertex.label_, vertex.vid_),
pk_prop->mutable_value());

for (size_t i = 0; i < names.size(); ++i) {
auto prop = v->add_properties();
prop->mutable_key()->set_name(names[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,20 @@ def test_x_csr_params(
start_service_on_graph(
interactive_session, create_graph_algo_graph_with_x_csr_params
)
ensure_compiler_schema_ready(
interactive_session, neo4j_session, create_graph_algo_graph_with_x_csr_params
)
result = neo4j_session.run('MATCH (n) where n.id <> "" return count(n);')
# expect return value 0
records = result.fetch(1)
print(records[0])
assert len(records) == 1 and records[0]["$f0"] == 3506


@pytest.mark.skipif(
os.environ.get("RUN_ON_PROTO", None) != "ON",
reason="var_char is only supported in proto",
)
def test_var_char_property(
interactive_session, neo4j_session, create_graph_with_var_char_property
):
Expand All @@ -392,6 +399,9 @@ def test_var_char_property(
interactive_session, create_graph_with_var_char_property
)
start_service_on_graph(interactive_session, create_graph_with_var_char_property)
ensure_compiler_schema_ready(
interactive_session, neo4j_session, create_graph_with_var_char_property
)
result = neo4j_session.run("MATCH (n: person) return n.name AS personName;")
records = result.fetch(10)
assert len(records) == 4
Expand Down
2 changes: 1 addition & 1 deletion flex/tests/hqps/hqps_robust_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ run_robust_test(){
run_additional_robust_test(){
pushd ${FLEX_HOME}/interactive/sdk/python/gs_interactive
export RUN_ON_PROTO=ON
cmd="python3 -m pytest -s tests/test_robustness.py -k test_call_proc_in_cypher"
cmd='python3 -m pytest -s tests/test_robustness.py -k "test_call_proc_in_cypher or test_var_char_property"'
echo "Run additional robust test with command: ${cmd}"
eval ${cmd} || (err "Run additional robust test failed"; exit 1)
info "Run additional robust test success"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.alibaba.graphscope.common.ir.meta.IrMetaStats;
import com.alibaba.graphscope.common.ir.meta.IrMetaTracker;
import com.alibaba.graphscope.common.ir.meta.reader.IrMetaReader;
import com.alibaba.graphscope.common.ir.meta.schema.SchemaSpec.Type;
import com.alibaba.graphscope.groot.common.schema.api.GraphStatistics;

import org.slf4j.Logger;
Expand Down Expand Up @@ -79,9 +78,6 @@ public Optional<IrMeta> fetch() {
private synchronized void syncMeta() {
try {
IrMeta meta = this.reader.readMeta();
logger.debug(
"schema from remote: {}",
(meta == null) ? null : meta.getSchema().getSchemaSpec(Type.IR_CORE_IN_JSON));
// if the graph id or schema version is changed, we need to update the statistics
if (this.currentState == null
|| !this.currentState.getGraphId().equals(meta.getGraphId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,21 @@ public static QueryContext get_simple_match_query_18_test() {
List<String> expected = Arrays.asList("Record<{$f0: 39783}>");
return new QueryContext(query, expected);
}

public static QueryContext get_simple_match_query_19_test() {
String query = "MATCH(a: PLACE) return a ORDER BY a.id limit 5;";
List<String> expected =
Arrays.asList(
"[a: {name=India, id=0, type=country,"
+ " url=http://dbpedia.org/resource/India}]",
"[a: {name=China, id=1, type=country,"
+ " url=http://dbpedia.org/resource/China}]",
"[a: {name=Angola, id=2, type=country,"
+ " url=http://dbpedia.org/resource/Angola}]",
"[a: {name=Austria, id=3, type=country,"
+ " url=http://dbpedia.org/resource/Austria}]",
"[a: {name=Azerbaijan, id=4, type=country,"
+ " url=http://dbpedia.org/resource/Azerbaijan}]");
return new QueryContext(query, expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,23 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.neo4j.driver.GraphDatabase;
import org.neo4j.driver.Record;
import org.neo4j.driver.Result;
import org.neo4j.driver.Session;
import org.neo4j.driver.Value;
import org.neo4j.driver.internal.types.InternalTypeSystem;
import org.neo4j.driver.types.Node;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class SimpleMatchTest {

private static final Logger logger = LoggerFactory.getLogger(SimpleMatchTest.class);

private static Session session;

@BeforeClass
Expand Down Expand Up @@ -169,6 +181,38 @@ public void run_simple_match_18_test() {
Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString());
}

@Test
public void run_simple_match_19_test() {
assumeTrue("hiactor".equals(System.getenv("ENGINE_TYPE")));
QueryContext testQuery = SimpleMatchQueries.get_simple_match_query_19_test();
Result result = session.run(testQuery.getQuery());
List<Record> records = result.list();
List<String> properties = new ArrayList<>();
records.forEach(
record -> {
properties.add(fetchAllProperties(record));
});
logger.info(properties.toString());
Assert.assertEquals(testQuery.getExpectedResult().toString(), properties.toString());
}

private static String fetchAllProperties(Record record) {
List<String> properties = new ArrayList<>();
record.keys()
.forEach(
key -> {
Value v = record.get(key);
if (v.hasType(InternalTypeSystem.TYPE_SYSTEM.NODE())) {
Node node = v.asNode();
Map<String, Object> nodeProperties = node.asMap();
properties.add(key + ": " + nodeProperties.toString());
} else {
properties.add(key + ": " + record.get(key).toString());
}
});
return properties.toString();
}

@AfterClass
public static void afterClass() {
if (session != null) {
Expand Down
Loading