Skip to content

Commit 10ed3b3

Browse files
authored
refactor(interactive): Add Error Codes in CompilePlan JNI Results (#4472)
<!-- Thanks for your contribution! please review https://github.com/alibaba/GraphScope/blob/main/CONTRIBUTING.md before opening an issue. --> ## What do these changes do? as titled. <!-- Please give a short brief about these changes. --> ## Related issue number <!-- Are there any issues opened that will be resolved by merging this change? --> Fixes
1 parent 71f99d9 commit 10ed3b3

File tree

13 files changed

+320
-159
lines changed

13 files changed

+320
-159
lines changed

docs/interactive_engine/graph_planner.md

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Plan GraphPlannerWrapper::CompilePlan(const std::string &compiler_config_path,
4242
const std::string &cypher_query_string,
4343
const std::string &graph_schema_yaml,
4444
const std::string &graph_statistic_json)
45+
4546
```
4647

4748
### Getting Started
@@ -74,31 +75,50 @@ To demonstrate the usage of the JNI interface, an example binary `test_graph_pla
7475
bin/test_graph_planner libs native ./conf/graph.yaml ./conf/modern_statistics.json "MATCH (n) RETURN n, COUNT(n);" ./conf/gs_interactive_hiactor.yaml
7576
```
7677

77-
The output consists of the physical plan (in byte format) and the result schema (in YAML format). The physical plan adheres to the specifications defined in the [protobuf]().
78-
79-
Below is an example of a result schema:
80-
81-
```yaml
82-
schema:
83-
name: default
84-
description: default desc
85-
mode: READ
86-
extension: .so
87-
library: libdefault.so
88-
params: []
89-
returns:
90-
- name: n
91-
type: {primitive_type: DT_UNKNOWN}
92-
- name: $f1
93-
type: {primitive_type: DT_SIGNED_INT64}
94-
type: UNKNOWN
95-
query: MATCH (n) RETURN n, COUNT(n);
96-
```
97-
98-
The `returns` field defines the structure of the data returned by backend engines. Each nested entry in the returns field includes three components:
99-
- the column name, which specifies the name of the result column;
100-
- the entry’s ordinal position, which determines the column ID;
101-
- the type, which enforces the data type constraint for the column.
78+
The output consists of three key fields:
79+
80+
1. Error code for plan compilation. The following table outlines the error codes, along with their corresponding descriptions:
81+
| Error Code | Description |
82+
| -------------------------- | ------------------------------------------------------------------------------------------------ |
83+
| OK | Query compilation succeeded. |
84+
| GREMLIN_INVALID_SYNTAX | The provided Gremlin query contains syntax errors. |
85+
| CYPHER_INVALID_SYNTAX | The provided Cypher query contains syntax errors. |
86+
| TAG_NOT_FOUND | The specified tag is not found in the current query context. |
87+
| LABEL_NOT_FOUND | The specified label is not found under the schema constraints. |
88+
| PROPERTY_NOT_FOUND | The specified property is not found under the schema constraints. |
89+
| TYPE_INFERENCE_FAILED | The query contains invalid graph patterns that violate schema constraints. |
90+
| LOGICAL_PLAN_BUILD_FAILED | An error occurred during logical plan optimization. The error message provides specific details. |
91+
| PHYSICAL_PLAN_BUILD_FAILED | An error occurred during physical plan construction. |
92+
| GREMLIN_INVALID_RESULT | An error occurred while parsing the Gremlin query results. |
93+
| CYPHER_INVALID_RESULT | An error occurred while parsing the Cypher query results. |
94+
| ENGINE_UNAVAILABLE | The lower execution engine is unavailable. |
95+
| QUERY_EXECUTION_TIMEOUT | The query execution time exceeded the predefined limit. |
96+
| META_SCHEMA_NOT_READY | The schema metadata is not ready for querying. |
97+
| META_STATISTICS_NOT_READY | The statistical metadata is not ready for querying. |
98+
| EMPTY_RESULT | The compilation determines that the query will produce an empty result. |
99+
2. Physical plan in byte format, adheres to the specifications defined in the [protobuf](https://github.com/alibaba/GraphScope/blob/main/interactive_engine/executor/ir/proto/physical.proto).
100+
3. Result schema in YAML format. Below is an example of a result schema:
101+
```yaml
102+
schema:
103+
name: default
104+
description: default desc
105+
mode: READ
106+
extension: .so
107+
library: libdefault.so
108+
params: []
109+
returns:
110+
- name: n
111+
type: {primitive_type: DT_UNKNOWN}
112+
- name: $f1
113+
type: {primitive_type: DT_SIGNED_INT64}
114+
type: UNKNOWN
115+
query: MATCH (n) RETURN n, COUNT(n);
116+
```
117+
118+
The `returns` field defines the structure of the data returned by backend engines. Each nested entry in the returns field includes three components:
119+
- the column name, which specifies the name of the result column;
120+
- the entry’s ordinal position, which determines the column ID;
121+
- the type, which enforces the data type constraint for the column.
102122

103123
## Restful API
104124

interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/GraphBuilder.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ private int generateAliasId(@Nullable String alias) {
322322
* @param opt anti or optional
323323
*/
324324
public GraphBuilder match(RelNode single, GraphOpt.Match opt) {
325+
// verify the hops in the sentence is valid
326+
new QueryExecutionValidator(configs).validate(new LogicalPlan(single), true);
325327
if (FrontendConfig.GRAPH_TYPE_INFERENCE_ENABLED.get(configs)) {
326328
single =
327329
new GraphTypeInference(
@@ -374,6 +376,9 @@ public GraphBuilder match(RelNode first, Iterable<? extends RelNode> others) {
374376
}
375377
Preconditions.checkArgument(
376378
sentences.size() > 1, "at least two sentences are required in multiple match");
379+
// verify the hops in each sentence is valid
380+
sentences.forEach(
381+
k -> new QueryExecutionValidator(configs).validate(new LogicalPlan(k), true));
377382
if (FrontendConfig.GRAPH_TYPE_INFERENCE_ENABLED.get(configs)) {
378383
sentences =
379384
new GraphTypeInference(

interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/GraphPlanner.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ public GraphPlanner(
8787
this.validator = new QueryExecutionValidator(graphConfig);
8888
}
8989

90+
public GraphRelOptimizer getOptimizer() {
91+
return optimizer;
92+
}
93+
9094
public PlannerInstance instance(String query, IrMeta irMeta) {
9195
return instance(query, irMeta, null);
9296
}

0 commit comments

Comments
 (0)