use of org.apache.hadoop.hive.ql.udf.generic.GenericUDFLower in project hive by apache.
the class TestVectorizationContext method testUnaryStringExpressions.
@Test
public void testUnaryStringExpressions() throws HiveException {
ExprNodeGenericFuncDesc stringUnary = new ExprNodeGenericFuncDesc();
stringUnary.setTypeInfo(TypeInfoFactory.stringTypeInfo);
ExprNodeColumnDesc colDesc = new ExprNodeColumnDesc(String.class, "a", "table", false);
List<ExprNodeDesc> children = new ArrayList<ExprNodeDesc>();
children.add(colDesc);
stringUnary.setChildren(children);
List<String> columns = new ArrayList<String>();
columns.add("b");
columns.add("a");
VectorizationContext vc = new VectorizationContext("name", columns);
GenericUDF stringLower = new GenericUDFLower();
stringUnary.setGenericUDF(stringLower);
VectorExpression ve = vc.getVectorExpression(stringUnary);
assertEquals(StringLower.class, ve.getClass());
assertEquals(1, ((StringLower) ve).getColNum());
assertEquals(2, ((StringLower) ve).getOutputColumn());
vc = new VectorizationContext("name", columns);
ExprNodeGenericFuncDesc anotherUnary = new ExprNodeGenericFuncDesc();
anotherUnary.setTypeInfo(TypeInfoFactory.stringTypeInfo);
List<ExprNodeDesc> children2 = new ArrayList<ExprNodeDesc>();
children2.add(stringUnary);
anotherUnary.setChildren(children2);
GenericUDFBridge udfbridge = new GenericUDFBridge("ltrim", false, GenericUDFLTrim.class.getName());
anotherUnary.setGenericUDF(udfbridge);
ve = vc.getVectorExpression(anotherUnary);
VectorExpression childVe = ve.getChildExpressions()[0];
assertEquals(StringLower.class, childVe.getClass());
assertEquals(1, ((StringLower) childVe).getColNum());
assertEquals(2, ((StringLower) childVe).getOutputColumn());
assertEquals(StringLTrim.class, ve.getClass());
assertEquals(2, ((StringLTrim) ve).getInputColumn());
assertEquals(3, ((StringLTrim) ve).getOutputColumn());
}
Aggregations