0

The hive UDTF I coded, works fine as along as the number of output columns specified is two. But the moment, I change it to three and redeploy, it says the following error message.

FAILED: SemanticException [Error 10083]: The number of aliases supplied in the AS clause does not match the number of columns output by the UDTF expected 2 aliases but got 3

Is there any reason for it ?

Here's the code block I am using in initialize method.

List<String> fieldNames = new ArrayList<String>(3);
List<ObjectInspector> fieldOIs = new ArrayList<ObjectInspector>(3);
fieldNames.add("word");
fieldNames.add("cnt");
fieldNames.add("ext");

fieldOIs.add(PrimitiveObjectInspectorFactory.javaStringObjectInspector);
fieldOIs.add(PrimitiveObjectInspectorFactory.javaIntObjectInspector);
fieldOIs.add(PrimitiveObjectInspectorFactory.javaIntObjectInspector);

return ObjectInspectorFactory.getStandardStructObjectInspector(fieldNames, fieldOIs);

Here's the forward statement in process method

forward(new Object[] { "abcdef", Integer.valueOf(123), Integer.valueOf(123)});

Any help appreciated.

1 Answers1

2

Solution is to close the current hive CLI session, open another hive session and deploying jar for the new changes in initialize() to take effect.

For changes to take effect in,

initialize() method --> restart a new hive CLI session and redeploy jar

process() method --> redeploying jar within the same session works !

It appears that the initialize() method is loaded per session only during the first deploy of the jar whereas the process() method is reloaded every time the jar is redeployed within the same session.

Since the information about number of columns is present in initialize() method, it was not working for any number of redeploys within the same session. It worked when I closed the sessions and started a fresh one before deploying the jar file.