phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JamesRTaylor <...@git.apache.org>
Subject [GitHub] phoenix pull request: PHOENIX-2288 Phoenix-Spark: PDecimal precisi...
Date Fri, 23 Oct 2015 00:47:34 GMT
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/124#discussion_r42823983
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java ---
    @@ -459,19 +459,30 @@ public static ColumnInfo getColumnInfo(PTable table, String columnName)
throws S
             return getColumnInfo(pColumn);
         }
     
    -   /**
    +    /**
          * Constructs a column info for the supplied pColumn
          * @param pColumn
          * @return columnInfo
          * @throws SQLException if the parameter is null.
          */
         public static ColumnInfo getColumnInfo(PColumn pColumn) throws SQLException {
    -        if (pColumn==null) {
    +        if (pColumn == null) {
                 throw new SQLException("pColumn must not be null.");
             }
             int sqlType = pColumn.getDataType().getSqlType();
    -        ColumnInfo columnInfo = new ColumnInfo(pColumn.toString(),sqlType);
    -        return columnInfo;
    +        if (pColumn.getMaxLength() == null) {
    +            return new ColumnInfo(pColumn.toString(), sqlType);
    +        }
    +        if (sqlType == Types.CHAR || sqlType == Types.VARCHAR) {
    --- End diff --
    
    Rather than check for particular types, it'd be more general to check for null like this:
    
        Integer maxLength = pColumn.getMaxLength();
        Integer scale = pColumn.getScale();
        return new ColumnInfo(pColumn.toString(), sqlType, maxLength, scale);
    
    Then make sure that ColumnInfo handles a null maxLength and scale.


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