You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hivemall.apache.org by my...@apache.org on 2019/02/14 06:07:19 UTC
[incubator-hivemall] branch master updated: Fixed CI error due to a
bug in unit test
This is an automated email from the ASF dual-hosted git repository.
myui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hivemall.git
The following commit(s) were added to refs/heads/master by this push:
new b4e4599 Fixed CI error due to a bug in unit test
b4e4599 is described below
commit b4e45992a8b572e3103c4cc20ba8b57878499bde
Author: Makoto Yui <my...@apache.org>
AuthorDate: Thu Feb 14 15:07:12 2019 +0900
Fixed CI error due to a bug in unit test
---
.../hivemall/tools/array/ToStringArrayUDFTest.java | 44 +++++++++++++++-------
1 file changed, 31 insertions(+), 13 deletions(-)
diff --git a/core/src/test/java/hivemall/tools/array/ToStringArrayUDFTest.java b/core/src/test/java/hivemall/tools/array/ToStringArrayUDFTest.java
index 132d5bc..e8ce84d 100644
--- a/core/src/test/java/hivemall/tools/array/ToStringArrayUDFTest.java
+++ b/core/src/test/java/hivemall/tools/array/ToStringArrayUDFTest.java
@@ -18,38 +18,56 @@
*/
package hivemall.tools.array;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import org.apache.hadoop.io.Text;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.junit.Assert;
import org.junit.Test;
public class ToStringArrayUDFTest {
@Test
- public void testTextArrayInput() {
- List<Text> input = new ArrayList<Text>(2);
- input.add(new Text("1"));
- input.add(new Text("2"));
+ public void testTextArrayInput() throws HiveException, IOException {
+ List<String> input = new ArrayList<String>(2);
+ input.add("1");
+ input.add("2");
ToStringArrayUDF udf = new ToStringArrayUDF();
- List<Text> output = udf.evaluate(input);
+ udf.initialize(new ObjectInspector[] {ObjectInspectorFactory.getStandardListObjectInspector(
+ PrimitiveObjectInspectorFactory.javaStringObjectInspector)});
- Assert.assertSame(input, output);
+ DeferredObject[] args = new DeferredObject[] {new GenericUDF.DeferredJavaObject(input)};
+ List<String> output = udf.evaluate(args);
+
+ Assert.assertEquals(input, output);
+
+ udf.close();
}
@Test
- public void testTextArrayInputWithNullValue() {
- List<Text> input = new ArrayList<Text>(2);
- input.add(new Text("1"));
+ public void testTextArrayInputWithNullValue() throws HiveException, IOException {
+ List<String> input = new ArrayList<String>(2);
+ input.add("1");
input.add(null);
- input.add(new Text("2"));
+ input.add("2");
ToStringArrayUDF udf = new ToStringArrayUDF();
- List<Text> output = udf.evaluate(input);
+ udf.initialize(new ObjectInspector[] {ObjectInspectorFactory.getStandardListObjectInspector(
+ PrimitiveObjectInspectorFactory.javaStringObjectInspector)});
+
+ DeferredObject[] args = new DeferredObject[] {new GenericUDF.DeferredJavaObject(input)};
+ List<String> output = udf.evaluate(args);
+
+ Assert.assertEquals(input, output);
- Assert.assertSame(input, output);
+ udf.close();
}
}