You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kudu.apache.org by "Greg Solovyev (Jira)" <ji...@apache.org> on 2020/06/19 03:37:00 UTC

[jira] [Updated] (KUDU-3152) KuduPredicate class in Java client does not handle Date columns

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

Greg Solovyev updated KUDU-3152:
--------------------------------
    Description: 
I ran into this trying to add a Date type field to nifi-kudu-controller-service (https://issues.apache.org/jira/browse/NIFI-7551). The following code throws  _java.lang.IllegalArgumentException_ if _sql_date_ column is defined as DATE and _value_ is either _java.sql.Date_ or _int_
{code:java}
KuduPredicate.newComparisonPredicate(tableSchema.getColumn("sql_date"), KuduPredicate.ComparisonOp.EQUAL, value){code}
If _value_ is DATE, _IllegalArgumentException_ is thrown by this code in KuduPredicate class:
static long minIntValue(Type type) {
  switch (type) {
    case INT8:
      return Byte.MIN_VALUE;
    case INT16:
      return Short.MIN_VALUE;
    case INT32:
      return Integer.MIN_VALUE;
    case UNIXTIME_MICROS:
    case INT64:
      return Long.MIN_VALUE;
    default:
      throw new IllegalArgumentException("type must be an integer type");
  }
}
if _value_ is an integer, then _IllegalArgumentException_ is thrown by this code
{code:java}
public static KuduPredicate newComparisonPredicate(ColumnSchema column,
                                                   ComparisonOp op,
                                                   long value) {
  checkColumn(column, Type.INT8, Type.INT16, Type.INT32, Type.INT64, Type.UNIXTIME_MICROS,
      Type.DATE);
{code}
as a result, if you have a table with DATE column, you cannot scan for it using the java client.

 

  was:
I ran into this trying to add a Date type field to nifi-kudu-controller-service (https://issues.apache.org/jira/browse/NIFI-7551). The following code throws 

_java.lang.IllegalArgumentException_
{code:java}
@Test
public void multi_key() {
    testRunner.setProperty(kuduLookupService, KuduLookupService.RETURN_COLUMNS, "*");    testRunner.enableControllerService(kuduLookupService);    Map<String,Object> map = new HashMap<>();
    map.put("string", "string1");
    map.put("binary", "binary1".getBytes());
    map.put("bool",true);
    map.put("decimal", BigDecimal.valueOf(0.1));
    map.put("double",0.2);
    map.put("float",0.3f);
    map.put("int8", (byte) 1);
    map.put("int16", (short) 2);
    map.put("int32",3);
    map.put("int64",4L);
    map.put("unixtime_micros", new Timestamp(nowMillis));
    map.put("sql_date", today);
    map.put("varchar_3", "SFO");
    Record result = kuduLookupService.lookup(map).get();
    validateRow1(result);
}
{code}


> KuduPredicate class in Java client does not handle Date columns
> ---------------------------------------------------------------
>
>                 Key: KUDU-3152
>                 URL: https://issues.apache.org/jira/browse/KUDU-3152
>             Project: Kudu
>          Issue Type: Bug
>            Reporter: Greg Solovyev
>            Priority: Major
>
> I ran into this trying to add a Date type field to nifi-kudu-controller-service (https://issues.apache.org/jira/browse/NIFI-7551). The following code throws  _java.lang.IllegalArgumentException_ if _sql_date_ column is defined as DATE and _value_ is either _java.sql.Date_ or _int_
> {code:java}
> KuduPredicate.newComparisonPredicate(tableSchema.getColumn("sql_date"), KuduPredicate.ComparisonOp.EQUAL, value){code}
> If _value_ is DATE, _IllegalArgumentException_ is thrown by this code in KuduPredicate class:
> static long minIntValue(Type type) {
>   switch (type) {
>     case INT8:
>       return Byte.MIN_VALUE;
>     case INT16:
>       return Short.MIN_VALUE;
>     case INT32:
>       return Integer.MIN_VALUE;
>     case UNIXTIME_MICROS:
>     case INT64:
>       return Long.MIN_VALUE;
>     default:
>       throw new IllegalArgumentException("type must be an integer type");
>   }
> }
> if _value_ is an integer, then _IllegalArgumentException_ is thrown by this code
> {code:java}
> public static KuduPredicate newComparisonPredicate(ColumnSchema column,
>                                                    ComparisonOp op,
>                                                    long value) {
>   checkColumn(column, Type.INT8, Type.INT16, Type.INT32, Type.INT64, Type.UNIXTIME_MICROS,
>       Type.DATE);
> {code}
> as a result, if you have a table with DATE column, you cannot scan for it using the java client.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)