1
votes

i'm using apache hive with and UDF function create in eclipse. So when i call the function in my sql query, i see this error:

FAILED: SemanticException [Error 10014]: Line 1:7 Wrong arguments 'summary': No matching method for class HiveUDF.TokenizeString with (string). Possible choices:

Where is the problem?

UDF CLASS

package HiveUDF;
public class TokenizeString extends UDF {

public List<String> tokenize (Text text) {
    List<String> prova = new ArrayList<String>();
    if(text == null)
        return null;
    String[] words = text.toString().split("\\n");
    for (String w : words)
        prova.add(w);
    return prova;
}

}

SQL TABLE AND QUERY

id                      bigint                                      
productid               string                                      
userid                  string                                      
profilename             string                                      
helpfulnessnumerator    int                                         
helpfulnessdenominator  int                                         
score                   float                                       
time                    int                                         
summary                 string                                      
text                    string

CREATE TEMPORARY FUNCTION tokenize_summary as 'HiveUDF.TokenizeString';

select tokenize_summary(summary) from amazonproduct;
2
the method must be named evaluate - franklinsijo

2 Answers

0
votes

when you extend UDF class, you must override evaluate(-) method.

0
votes
package HiveUDF;
public class TokenizeString extends UDF {
public List<String> evaulate (Text text) {
    List<String> prova = new ArrayList<String>();
    if(text == null)
        return null;
    String[] words = text.toString().split("\\n");
    for (String w : words)
        prova.add(w);
    return prova;
}
}

try this ...