Repository: phoenix
Updated Branches:
  refs/heads/calcite cca7daaea -> 9ac3aa83e


PHOENIX-3766 Avoid creating a cast for ROW data type


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/9ac3aa83
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/9ac3aa83
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/9ac3aa83

Branch: refs/heads/calcite
Commit: 9ac3aa83e32da071ab351c820865d05fc0315ded
Parents: cca7daa
Author: maryannxue <maryann....@gmail.com>
Authored: Wed Apr 5 12:54:31 2017 -0700
Committer: maryannxue <maryann....@gmail.com>
Committed: Wed Apr 5 12:54:57 2017 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/phoenix/calcite/CalciteUtils.java  | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/9ac3aa83/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java 
b/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java
index 32e89a4..2ab9007 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java
@@ -155,6 +155,7 @@ import org.apache.phoenix.schema.types.PDouble;
 import org.apache.phoenix.schema.types.PLong;
 import org.apache.phoenix.schema.types.PTimestamp;
 import org.apache.phoenix.schema.types.PUnsignedTimestamp;
+import org.apache.phoenix.schema.types.PVarchar;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
@@ -704,6 +705,9 @@ public class CalciteUtils {
                        public Expression newExpression(RexNode node, 
PhoenixRelImplementor implementor) {
                                RexLiteral lit = (RexLiteral) node;
                 PDataType targetType = relDataTypeToPDataType(node.getType());
+                if (targetType == PChar.INSTANCE) {
+                    targetType = PVarchar.INSTANCE;
+                }
                                Object o = lit.getValue();
                                if (o instanceof NlsString) {
                                    o = ((NlsString) o).getValue();
@@ -784,7 +788,10 @@ public class CalciteUtils {
             public Expression newExpression(RexNode node,
                     PhoenixRelImplementor implementor) {                
                 List<Expression> children = convertChildren((RexCall) node, 
implementor);
-                PDataType targetType = relDataTypeToPDataType(node.getType());
+                RelDataType type = node.getType();
+                if (type.getSqlTypeName() == SqlTypeName.ROW)
+                    return children.get(0);
+                PDataType targetType = relDataTypeToPDataType(type);
                 Integer maxLength =
                         (targetType == PChar.INSTANCE
                             || targetType == PCharArray.INSTANCE

Reply via email to