You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kudu.apache.org by Renato Marroquín Mogrovejo <re...@gmail.com> on 2016/01/06 18:38:46 UTC

Issue using Nullable fields with Java Client

Hi all,

I have used a C++ program to populate Kudu tables, and set the "Not Null"
flag accordingly. I have verified this using the kudu-client dump table
option available, but when using the Java client, I can not get the resutls
because it always throws an IllegalArgumentException("The requested column
(" + columnIndex + ") is null");
I have looked through the ResultSet java code[1], and it seems somehow
fishy because if the column has been set to be nullable, and you are seeing
a null value, why would throw an exception all times? Or is there anything
obvious that I might have overlooked? Or do I need to encode the NULL
values of my data in a different way for now?
Thanks!


Renato M.

[1]
https://github.com/cloudera/kudu/blob/master/java/kudu-client/src/main/java/org/kududb/client/RowResult.java#L238

Re: Issue using Nullable fields with Java Client

Posted by Renato Marroquín Mogrovejo <re...@gmail.com>.
Thanks Todd!

Renato M.
On Jan 6, 2016 6:58 PM, "Todd Lipcon" <to...@cloudera.com> wrote:

> Renato also asked this on slack, but just to relay this convo back to the
> user list:
>
> The issue is that the RowResult getter APIs in Java do not return boxed
> values. Since they return primitives, there's no way for us to return
> 'null' for a null cell, and it doesn't seem to quite make sense to return
> an arbitrary value like 0 or -1. So, getters throw exceptions for null
> values in this API. The solution is to do something like:
>
> // Fill in a default value like 0:
> long myVal = row.isNull(colIdx) ? 0 : row.getLong(colIdx);
>
> // Or, do your own boxing:
> Long myVal = row.isNull(colIdx) ? null : row.getLong(colIdx);
>
> Of course the second approach can have some performance issues due to
> creation of the box object.
>
> -Todd
>
> On Wed, Jan 6, 2016 at 9:38 AM, Renato Marroquín Mogrovejo <
> renatoj.marroquin@gmail.com> wrote:
>
>> Hi all,
>>
>> I have used a C++ program to populate Kudu tables, and set the "Not Null"
>> flag accordingly. I have verified this using the kudu-client dump table
>> option available, but when using the Java client, I can not get the resutls
>> because it always throws an IllegalArgumentException("The requested
>> column (" + columnIndex + ") is null");
>> I have looked through the ResultSet java code[1], and it seems somehow
>> fishy because if the column has been set to be nullable, and you are seeing
>> a null value, why would throw an exception all times? Or is there anything
>> obvious that I might have overlooked? Or do I need to encode the NULL
>> values of my data in a different way for now?
>> Thanks!
>>
>>
>> Renato M.
>>
>> [1]
>> https://github.com/cloudera/kudu/blob/master/java/kudu-client/src/main/java/org/kududb/client/RowResult.java#L238
>>
>
>
>
> --
> Todd Lipcon
> Software Engineer, Cloudera
>

Re: Issue using Nullable fields with Java Client

Posted by Todd Lipcon <to...@cloudera.com>.
Renato also asked this on slack, but just to relay this convo back to the
user list:

The issue is that the RowResult getter APIs in Java do not return boxed
values. Since they return primitives, there's no way for us to return
'null' for a null cell, and it doesn't seem to quite make sense to return
an arbitrary value like 0 or -1. So, getters throw exceptions for null
values in this API. The solution is to do something like:

// Fill in a default value like 0:
long myVal = row.isNull(colIdx) ? 0 : row.getLong(colIdx);

// Or, do your own boxing:
Long myVal = row.isNull(colIdx) ? null : row.getLong(colIdx);

Of course the second approach can have some performance issues due to
creation of the box object.

-Todd

On Wed, Jan 6, 2016 at 9:38 AM, Renato Marroquín Mogrovejo <
renatoj.marroquin@gmail.com> wrote:

> Hi all,
>
> I have used a C++ program to populate Kudu tables, and set the "Not Null"
> flag accordingly. I have verified this using the kudu-client dump table
> option available, but when using the Java client, I can not get the resutls
> because it always throws an IllegalArgumentException("The requested
> column (" + columnIndex + ") is null");
> I have looked through the ResultSet java code[1], and it seems somehow
> fishy because if the column has been set to be nullable, and you are seeing
> a null value, why would throw an exception all times? Or is there anything
> obvious that I might have overlooked? Or do I need to encode the NULL
> values of my data in a different way for now?
> Thanks!
>
>
> Renato M.
>
> [1]
> https://github.com/cloudera/kudu/blob/master/java/kudu-client/src/main/java/org/kududb/client/RowResult.java#L238
>



-- 
Todd Lipcon
Software Engineer, Cloudera