Try "Double[]". Primitive arrays (like double[], int[]) are not supported yet, because that needs special handling for each of the primitive type.
Zheng On Wed, Mar 10, 2010 at 4:55 PM, tom kersnick <[email protected]> wrote: > Gents, > > Any ideas why this happens? Im using hive 0.50 with hadoop 20.2. > > This is a super simple UDF..... > > Im just taking the length of the values and then dividing by pi. It keeps > popping up with this error: > > FAILED: Unknown exception: [D cannot be cast to [Ljava.lang.Object; > > Here is my approach: > > > package com.xyz.udf; > > import org.apache.hadoop.hive.ql.exec.UDF; > import java.util.Collections; > > > public final class test extends UDF { > public double evaluate(double[] values) { > final Integer len = values.length; > final Integer pi = len / 3.14159265; > return values[pi]; > } > } > > > hive> list > jars; > hive> add jar /tmp/hive_aux/x-y-z-udf-1.0-SNAPSHOT.jar; > Added /tmp/hive_aux/x-y-z-udf-1.0-SNAPSHOT.jar to class path > hive> create temporary function my_test as 'com.xyz.udf.test'; > OK > Time taken: 0.41 seconds > hive> show > tables; > OK > userpool > test > Time taken: 3.167 seconds > hive> describe userpool; > OK > word string > amount int > Time taken: 0.098 seconds > hive> select my_test(amount) from > userpool; > FAILED: Unknown exception: [D cannot be cast to [Ljava.lang.Object; > hive> describe test; > OK > word string > amount string > Time taken: 0.134 seconds > hive> select my_test(amount) from > test; > FAILED: Unknown exception: [D cannot be cast to [Ljava.lang.Object; > > > Thanks in advance! > > /tom > -- Yours, Zheng
