[ 
https://issues.apache.org/jira/browse/PHOENIX-3355?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15606368#comment-15606368
 ] 

Maryann Xue edited comment on PHOENIX-3355 at 10/25/16 8:26 PM:
----------------------------------------------------------------

[~rajeshbabu], Take a closer look at the plan with default values. Calcite 
interpret the default value as a special sql operator "DEFAULT()", and we did 
not handle that operator in our translation logic yet. So try adding the 
following to your CalciteUtils.java, and it'll work fine.
{code}
@@ -734,6 +734,18 @@ public class CalciteUtils {
                 }
             }
         });
+        EXPRESSION_MAP.put(SqlKind.DEFAULT, new ExpressionFactory() {
+            @SuppressWarnings("rawtypes")
+            @Override
+            public Expression newExpression(RexNode node, 
PhoenixRelImplementor implementor) {
+                PDataType targetType = relDataTypeToPDataType(node.getType());
+                try {
+                    return LiteralExpression.newConstant(null, targetType);
+                } catch (SQLException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+               });
         EXPRESSION_MAP.put(SqlKind.OTHER_FUNCTION, new ExpressionFactory() {
             @Override
             public Expression newExpression(RexNode node,
{code}


was (Author: maryannxue):
[~rajeshbabu], Take a closer look at the plan with default values. Calcite 
interpret the default value as a special sql operator "DEFAULT()", and we did 
not handle that operator in our translation logic yet. So try adding the 
following to your CalciteUtils.java, and it'll work fine.
{code}
@@ -734,6 +734,18 @@ public class CalciteUtils {
                 }
             }
         });
+               EXPRESSION_MAP.put(SqlKind.DEFAULT, new ExpressionFactory() {
+            @SuppressWarnings("rawtypes")
+            @Override
+            public Expression newExpression(RexNode node, 
PhoenixRelImplementor implementor) {
+                PDataType targetType = relDataTypeToPDataType(node.getType());
+                try {
+                    return LiteralExpression.newConstant(null, targetType);
+                } catch (SQLException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+               });
         EXPRESSION_MAP.put(SqlKind.OTHER_FUNCTION, new ExpressionFactory() {
             @Override
             public Expression newExpression(RexNode node,
{code}

> Register Phoenix built-in functions as Calcite functions
> --------------------------------------------------------
>
>                 Key: PHOENIX-3355
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-3355
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: James Taylor
>            Assignee: Eric Lomore
>              Labels: calcite
>         Attachments: PHOENIX-3355.wip
>
>
> We should register all Phoenix built-in functions that don't exist in Calcite.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to