kudu-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Todd Lipcon <t...@cloudera.com>
Subject Re: Issue using Nullable fields with Java Client
Date Wed, 06 Jan 2016 17:58:23 GMT
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.


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

View raw message