[ 
https://issues.apache.org/jira/browse/PHOENIX-2454?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hanwei Jin updated PHOENIX-2454:
--------------------------------
    Comment: was deleted

(was: Hi, I have done the unit test. But, come to a problem.

If I write Null into the table (Double Type Column) , it would be fine for 
writing. However, after the cell is filled, I read the row by HadoopAPI and it 
will get 0.0 as default value.

test data:  val dataset = Seq((1, 123.0, "String1"), (2, Double.NaN, 
"String2"), (3, Float.NaN, "String3"), (4, 456, null))
and here is the sql query result:
id: 1 double value: 123.0 string value: String1
id: 2 double value: 0.0 string value: String2
id: 3 double value: 0.0 string value: String3
id: 4 double value: 456.0 string value: null

Any suggestion? Or It is already the optimal solution?)

> Upsert with Double.NaN returns NumberFormatException
> ----------------------------------------------------
>
>                 Key: PHOENIX-2454
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2454
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: alex kamil
>            Priority: Minor
>              Labels: newbie
>             Fix For: 4.8.0
>
>
> When saving Double.NaN via prepared statement into column of type Double 
> getting NumberFormatException (while expected behavior is saving null)
> test case:
> {code}
> import java.sql.*;
> public static void main(String [] args){
>   try {
>         Connection phoenixConnection = 
> DriverManager.getConnection("jdbc:phoenix:localhost");
>         String sql  = "CREATE TABLE test25 (id BIGINT not null primary key,  
> col1 double, col2 double)";
>         Statement stmt = phoenixConnection.createStatement();
>         stmt.executeUpdate(sql);
>         phoenixConnection.commit();
>         
>         sql = "UPSERT INTO test25 (id, col1,col2) VALUES (?,?,?)";
>         PreparedStatement ps = phoenixConnection.prepareStatement(sql);
>         ps.setInt(1, 12);
>         ps.setDouble(2, 2.5);
>         ps.setDouble(3, Double.NaN);
>         ps.executeUpdate();
>         phoenixConnection.commit();
>         phoenixConnection.close();
>         } catch (Exception e) {
>                e.printStackTrace();
>         }
> }
> {code}



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

Reply via email to