Github user twdsilva commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/101#discussion_r36479562
--- Diff:
phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java
---
@@ -1339,4 +1362,193 @@ public Expression visit(SubqueryParseNode node)
throws SQLException {
public int getTotalNodeCount() {
return totalNodeCount;
}
+ //JSON node
+ @Override
+ public boolean visitEnter(JsonSingleKeySearchParseNode node) {
+ return true;
+ }
+
+ @Override
+ public boolean visitEnter(JsonContainWithinRightParseNode node) {
+ return true;
+ }
+
+ @Override
+ public boolean visitEnter(JsonContainWithinLeftParseNode node) {
+ return true;
+ }
+
+ @Override
+ public boolean visitEnter(JsonMultiKeySearchOrParseNode node) {
+ return true;
+ }
+
+ @Override
+ public boolean visitEnter(JsonMultiKeySearchAndParseNode node) {
+ return true;
+ }
+
+ @Override
+ public boolean visitEnter(JsonPathAsTextParseNode node) {
+ return true;
+ }
+
+ @Override
+ public boolean visitEnter(JsonPathAsElementParseNode node) {
+ return true;
+ }
+
+ @Override
+ public boolean visitEnter(JsonPointAsElementParseNode node) throws
SQLException {
+ return true;
+ }
+
+ @Override
+ public boolean visitEnter(JsonPointAsTextParseNode node){
+ return true;
+ }
+
+
+ @Override
+ public Expression visitLeave(JsonSingleKeySearchParseNode node,
List<Expression> children) throws SQLException {
+ ParseNode rhsNode = node.getChildren().get(1);
+ Expression lhs = children.get(0);
+ if (rhsNode instanceof BindParseNode) {
+
context.getBindManager().addParamMetaData((BindParseNode)rhsNode, lhs);
+ }
+
if(!(PJson.INSTANCE.isComparableTo(children.get(0).getDataType()))){
+ throw
TypeMismatchException.newException(children.get(0).getDataType(),
children.get(1).getDataType());
+ }
+
if(!(PVarchar.INSTANCE.isComparableTo(children.get(1).getDataType()))){
+ throw
TypeMismatchException.newException(children.get(0).getDataType(),
children.get(1).getDataType());
+ }
+ Expression expression = new
JsonSingleKeySearchExpression(children);
+ return wrapGroupByExpression(expression);
+ }
+
+ @Override
+ public Expression visitLeave(JsonContainWithinRightParseNode node,
List<Expression> children) throws SQLException {
+ ParseNode lhsNode = node.getChildren().get(0);
+ ParseNode rhsNode = node.getChildren().get(1);
+ Expression lhs = children.get(0);
+ Expression rhs = children.get(1);
+ if (lhsNode instanceof BindParseNode) {
+
context.getBindManager().addParamMetaData((BindParseNode)lhsNode, rhs);
+ }
+ if (rhsNode instanceof BindParseNode) {
+
context.getBindManager().addParamMetaData((BindParseNode)rhsNode, lhs);
+ }
+
if(!(PJson.INSTANCE.isComparableTo(children.get(0).getDataType()))){
+ throw
TypeMismatchException.newException(children.get(0).getDataType(),
children.get(1).getDataType());
+ }
+
if(!(PJson.INSTANCE.isComparableTo(children.get(1).getDataType()))){
+ throw
TypeMismatchException.newException(children.get(0).getDataType(),
children.get(1).getDataType());
+ }
+ Expression expression = new
JsonContainWithinRightExpression(children);
+ return wrapGroupByExpression(expression);
+ }
+
+ @Override
+ public Expression visitLeave(JsonContainWithinLeftParseNode node,
List<Expression> children) throws SQLException {
+ ParseNode lhsNode = node.getChildren().get(0);
+ ParseNode rhsNode = node.getChildren().get(1);
+ Expression lhs = children.get(0);
+ Expression rhs = children.get(1);
+ if (lhsNode instanceof BindParseNode) {
+
context.getBindManager().addParamMetaData((BindParseNode)lhsNode, rhs);
+ }
+ if (rhsNode instanceof BindParseNode) {
+
context.getBindManager().addParamMetaData((BindParseNode)rhsNode, lhs);
+ }
+
if(!(PJson.INSTANCE.isComparableTo(children.get(0).getDataType()))){
+ throw
TypeMismatchException.newException(children.get(0).getDataType(),
children.get(1).getDataType());
+ }
+
if(!(PJson.INSTANCE.isComparableTo(children.get(1).getDataType()))){
+ throw
TypeMismatchException.newException(children.get(0).getDataType(),
children.get(1).getDataType());
+ }
+ Expression expression = new
JsonContainWithinLeftExpression(children);
+ return wrapGroupByExpression(expression);
+ }
+
--- End diff --
For JsonMultiKeySearchOrParseNode and JsonMultiKeySearchAndParseNode do
you need to check if the lhsNodeis / rhsNode are instances of BindParseNode ?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---