-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GIE Compiler] Support dynamic query params in cypher queries (#2874)
<!-- 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 #2713 --------- Co-authored-by: BingqingLyu <bingqing.lbq@alibaba-inc.com> Co-authored-by: Longbin Lai <longbin.lailb@alibaba-inc.com>
- Loading branch information
1 parent
ce3e16b
commit a18836d
Showing
28 changed files
with
631 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...ine/compiler/src/main/java/com/alibaba/graphscope/common/ir/rex/RexGraphDynamicParam.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2020 Alibaba Group Holding Limited. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.alibaba.graphscope.common.ir.rex; | ||
|
||
import org.apache.calcite.rel.type.RelDataType; | ||
import org.apache.calcite.rex.RexDynamicParam; | ||
|
||
public class RexGraphDynamicParam extends RexDynamicParam { | ||
private final String paramName; | ||
|
||
public RexGraphDynamicParam(RelDataType type, String paramName, int index) { | ||
super(type, index); | ||
this.paramName = paramName; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return paramName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...ine/compiler/src/main/java/com/alibaba/graphscope/common/ir/rex/RexNodeTypeRefresher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2020 Alibaba Group Holding Limited. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.alibaba.graphscope.common.ir.rex; | ||
|
||
import com.alibaba.graphscope.common.ir.tools.GraphRexBuilder; | ||
|
||
import org.apache.calcite.rel.type.RelDataType; | ||
import org.apache.calcite.rex.*; | ||
|
||
public class RexNodeTypeRefresher extends RexVisitorImpl<RexNode> { | ||
private final RelDataType newType; | ||
private final GraphRexBuilder rexBuilder; | ||
|
||
public RexNodeTypeRefresher(RelDataType newType, GraphRexBuilder rexBuilder) { | ||
super(false); | ||
this.newType = newType; | ||
this.rexBuilder = rexBuilder; | ||
} | ||
|
||
@Override | ||
public RexNode visitCall(RexCall call) { | ||
return call; | ||
} | ||
|
||
@Override | ||
public RexNode visitLiteral(RexLiteral literal) { | ||
return literal; | ||
} | ||
|
||
@Override | ||
public RexNode visitInputRef(RexInputRef inputRef) { | ||
return inputRef; | ||
} | ||
|
||
@Override | ||
public RexNode visitDynamicParam(RexDynamicParam dynamicParam) { | ||
if (dynamicParam instanceof RexGraphDynamicParam) { | ||
return visitGraphDynamicParam((RexGraphDynamicParam) dynamicParam); | ||
} else { | ||
return dynamicParam; | ||
} | ||
} | ||
|
||
private RexNode visitGraphDynamicParam(RexGraphDynamicParam graphDynamicParam) { | ||
return rexBuilder.makeGraphDynamicParam( | ||
newType, graphDynamicParam.getName(), graphDynamicParam.getIndex()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/GraphRexBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2020 Alibaba Group Holding Limited. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.alibaba.graphscope.common.ir.tools; | ||
|
||
import com.alibaba.graphscope.common.ir.rex.RexGraphDynamicParam; | ||
|
||
import org.apache.calcite.rel.type.RelDataType; | ||
import org.apache.calcite.rel.type.RelDataTypeFactory; | ||
import org.apache.calcite.rex.RexBuilder; | ||
|
||
public class GraphRexBuilder extends RexBuilder { | ||
public GraphRexBuilder(RelDataTypeFactory typeFactory) { | ||
super(typeFactory); | ||
} | ||
|
||
public RexGraphDynamicParam makeGraphDynamicParam(String name, int index) { | ||
return makeGraphDynamicParam(getTypeFactory().createUnknownType(), name, index); | ||
} | ||
|
||
public RexGraphDynamicParam makeGraphDynamicParam( | ||
RelDataType dataType, String name, int index) { | ||
return new RexGraphDynamicParam(dataType, name, index); | ||
} | ||
} |
Oops, something went wrong.