[
https://issues.apache.org/jira/browse/PHOENIX-2144?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14644498#comment-14644498
]
ASF GitHub Bot commented on PHOENIX-2144:
-----------------------------------------
Github user petercdc commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/101#discussion_r35658016
--- Diff:
phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java
---
@@ -1339,4 +1363,188 @@ 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(JsonSubsetParseNode node) {
+ return true;
+ }
+
+ @Override
+ public boolean visitEnter(JsonSupersetParseNode node) {
+ return true;
+ }
+
+ @Override
+ public boolean visitEnter(JsonMultiKeySearchOrParseNode node) {
+ return true;
+ }
+
+ @Override
+ public boolean visitEnter(JsonMultiKeySeatchAndParseNode 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 {
+
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(JsonSubsetParseNode node,
List<Expression> children) throws SQLException {
+
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());
+ }
+ LiteralExpression rhs=(LiteralExpression)children.get(1);
+ Expression expression = new JsonSubsetExpression(children);
+ return wrapGroupByExpression(expression);
+ }
+
+ @Override
+ public Expression visitLeave(JsonSupersetParseNode node,
List<Expression> children) throws SQLException {
+
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());
+ }
+ LiteralExpression rhs=(LiteralExpression)children.get(1);
+ Expression expression = new JsonSupersetExpression(children);
+ return wrapGroupByExpression(expression);
+ }
+
+ @Override
+ public Expression visitLeave(JsonMultiKeySearchOrParseNode node,
List<Expression> children) throws SQLException {
+
if(!(PJson.INSTANCE.isComparableTo(children.get(0).getDataType()))){
+ throw
TypeMismatchException.newException(children.get(0).getDataType(),
children.get(1).getDataType());
+ }
+ if(children.get(1).getDataType()!=PVarcharArray.INSTANCE){
+ throw
TypeMismatchException.newException(children.get(0).getDataType(),
children.get(1).getDataType());
+ }
+ Expression expression = new
JsonMultiKeySearchOrExpression(children);
+ return wrapGroupByExpression(expression);
+ }
+
+ @Override
+ public Expression visitLeave(JsonMultiKeySeatchAndParseNode node,
List<Expression> children) throws SQLException {
+
if(!(PJson.INSTANCE.isComparableTo(children.get(0).getDataType()))){
+ throw
TypeMismatchException.newException(children.get(0).getDataType(),
children.get(1).getDataType());
+ }
+ if(children.get(1).getDataType()!=PVarcharArray.INSTANCE){
+ throw
TypeMismatchException.newException(children.get(0).getDataType(),
children.get(1).getDataType());
+ }
+ Expression expression = new
JsonMultiKeySearchAndExpression(children);
+ return wrapGroupByExpression(expression);
+ }
+
+ @Override
+ public Expression visitLeave(JsonPathAsTextParseNode node,
List<Expression> children) throws SQLException {
+
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()))){
--- End diff --
Because the grammar in postgreSQL of #> and #>> will be
````
json_column #> '{key,index....}'
json_column #>> '{key,index...}'
````
is different with the type of varchar array , so we need to add some decode
function to decode these format
> Implement JSON operators
> -------------------------
>
> Key: PHOENIX-2144
> URL: https://issues.apache.org/jira/browse/PHOENIX-2144
> Project: Phoenix
> Issue Type: Sub-task
> Reporter: Thomas D'Silva
> Fix For: 5.0.0, 4.4.1
>
>
> See http://www.postgresql.org/docs/9.4/static/functions-json.html
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)