drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinfengni <...@git.apache.org>
Subject [GitHub] drill pull request #819: DRILL-5419: Calculate return string length for lite...
Date Thu, 27 Apr 2017 21:55:46 GMT
Github user jinfengni commented on a diff in the pull request:

    https://github.com/apache/drill/pull/819#discussion_r113812071
  
    --- Diff: common/src/main/java/org/apache/drill/common/types/Types.java ---
    @@ -636,43 +658,63 @@ public static String toString(final MajorType type) {
     
       /**
        * Get the <code>precision</code> of given type.
    -   * @param majorType
    -   * @return
    +   *
    +   * @param majorType major type
    +   * @return precision value
        */
       public static int getPrecision(MajorType majorType) {
    -    MinorType type = majorType.getMinorType();
    -
    -    if (type == MinorType.VARBINARY || type == MinorType.VARCHAR) {
    -      return 65536;
    -    }
    -
         if (majorType.hasPrecision()) {
           return majorType.getPrecision();
         }
     
    -    return 0;
    +    return isScalarStringType(majorType) ? MAX_VARCHAR_LENGTH : UNDEFINED;
    --- End diff --
    
    I believe what this PR tries to do is exactly as what you describe : derive length based
on metadata. Such metadata comes from the function used , or the string literal.  For example,
if you have a cast(some_input as varchar(20)), you will know the output type's max length
is 20 (depending on the input, the output may only have values up to 15 characters).   
    
    The max length is different from what could be obtained from {{RecordBatchSizer}}. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message