[ 
https://issues.apache.org/jira/browse/PHOENIX-2288?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14989982#comment-14989982
 ] 

James Taylor commented on PHOENIX-2288:
---------------------------------------

I think that's an improvement, but how about the following change to get rid of 
the type comparisons? {code}
+    public static ColumnInfo create(String columnName, int sqlType, Integer 
maxLength, Integer scale) {
+        if (scale != null) {
+            assert(maxLength != null); // If we have a scale, we should always 
have a max length
+            scale = scale == null ? 0 : Math.min(maxLength, scale);
+            return new ColumnInfo(columnName, sqlType, maxLength, scale);
+        }
+        if (maxLength != null) {
+            return new ColumnInfo(columnName, sqlType, maxLength);
+        }
+        return new ColumnInfo(columnName, sqlType);
+    }
+    
{code}
Needs tests for var length, fixed length, and arrays, for example:
{code}
    col1 CHAR(3) ARRAY, col2 DECIMAL(10,2) ARRAY, col3 VARCHAR(4) ARRAY,
    col4 VARCHAR(5), col5 CHAR(3), col6 VARCHAR, col7 DECIMAL(8,2)
{code}


> Phoenix-Spark: PDecimal precision and scale aren't carried through to Spark 
> DataFrame
> -------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-2288
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2288
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.5.2
>            Reporter: Josh Mahonin
>         Attachments: PHOENIX-2288.patch
>
>
> When loading a Spark dataframe from a Phoenix table with a 'DECIMAL' type, 
> the underlying precision and scale aren't carried forward to Spark.
> The Spark catalyst schema converter should load these from the underlying 
> column. These appear to be exposed in the ResultSetMetaData, but if there was 
> a way to expose these somehow through ColumnInfo, it would be cleaner.
> I'm not sure if Pig has the same issues or not, but I suspect it may.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to