You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by jinfengni <gi...@git.apache.org> on 2017/05/01 17:41:24 UTC

[GitHub] drill pull request #819: DRILL-5419: Calculate return string length for lite...

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

    https://github.com/apache/drill/pull/819#discussion_r114162499
  
    --- 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 --
    
    The way this PR calculates the maximum length is not from "guess". The metadata information leveraged in this PR is in the "query" itself ( the function appearing in the query, or the string literal in the query). It does not apply to all the queries; only when the query provides enough information Drill will calculate the maximum length. In all other cases, Drill will perform same as before.
    
    The maximum length (L1) calculated in this PR is different different from what you describe in the case of scanner (L2).  L2 <= L1. In the example of scanner with no metadata available, there would be no schema change; the precision is unset in type field, same as before. 
     
    @arina-ielchiieva can correct me if my understanding is wrong. 


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