Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/incubator-phoenix/pull/8#discussion_r10159042
  
    --- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/expression/LiteralExpression.java 
---
    @@ -156,6 +162,9 @@ public static LiteralExpression newConstant(Object 
value, PDataType type, Intege
                 throw TypeMismatchException.newException(type, actualType, 
value.toString());
             }
             value = type.toObject(value, actualType);
    +        if(type == PDataType.CHAR_ARRAY) {
    --- End diff --
    
    Then during upsert, there are two calls you should make sure work correctly 
for arrays:
    
                        if 
(!column.getDataType().isSizeCompatible(column.getDataType(),
                                value, byteValue,
                                precision, column.getMaxLength(), 
                                scale, column.getScale())) {
                            throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.DATA_INCOMPATIBLE_WITH_TYPE)
                                
.setColumnName(column.getName().getString()).build().buildException();
                        }
                        values[i] = column.getDataType().coerceBytes(byteValue, 
value, column.getDataType(),
                                precision, scale, column.getMaxLength(), 
column.getScale());
    
    The isSizeCompatible can check that the declared maxLength is greater than 
or equal to the value's maxLength. Then the coerceBytes would potentially need 
to create a new PhoenixArray if the column maxLength is greater than the 
value's maxLength.
    
    I think that should work.


---
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.
---

Reply via email to