Search in sources :

Example 1 with CollectOperator

use of org.apache.hadoop.hive.ql.exec.CollectOperator in project hive by apache.

the class BaseScalarUdfTest method testUdf.

/**
 * This method drives the test. It takes the data from getBaseTable() and
 * feeds it through a SELECT operator with a COLLECT operator after. Each
 * row that is produced by the collect operator is compared to getExpectedResult()
 * and if every row is the expected result the method completes without asserting.
 * @throws HiveException
 */
@Test
public final void testUdf() throws Exception {
    InspectableObject[] data = getBaseTable();
    List<ExprNodeDesc> expressionList = getExpressionList();
    SelectDesc selectCtx = new SelectDesc(expressionList, OperatorTestUtils.createOutputColumnNames(expressionList));
    Operator<SelectDesc> op = OperatorFactory.get(new CompilationOpContext(), SelectDesc.class);
    op.setConf(selectCtx);
    CollectDesc cd = new CollectDesc(Integer.valueOf(10));
    CollectOperator cdop = (CollectOperator) OperatorFactory.getAndMakeChild(cd, op);
    op.initialize(new JobConf(OperatorTestUtils.class), new ObjectInspector[] { data[0].oi });
    OperatorTestUtils.assertResults(op, cdop, data, getExpectedResult());
}
Also used : InspectableObject(org.apache.hadoop.hive.serde2.objectinspector.InspectableObject) CollectDesc(org.apache.hadoop.hive.ql.plan.CollectDesc) CompilationOpContext(org.apache.hadoop.hive.ql.CompilationOpContext) CollectOperator(org.apache.hadoop.hive.ql.exec.CollectOperator) ExprNodeDesc(org.apache.hadoop.hive.ql.plan.ExprNodeDesc) SelectDesc(org.apache.hadoop.hive.ql.plan.SelectDesc) JobConf(org.apache.hadoop.mapred.JobConf) Test(org.junit.Test)

Aggregations

CompilationOpContext (org.apache.hadoop.hive.ql.CompilationOpContext)1 CollectOperator (org.apache.hadoop.hive.ql.exec.CollectOperator)1 CollectDesc (org.apache.hadoop.hive.ql.plan.CollectDesc)1 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)1 SelectDesc (org.apache.hadoop.hive.ql.plan.SelectDesc)1 InspectableObject (org.apache.hadoop.hive.serde2.objectinspector.InspectableObject)1 JobConf (org.apache.hadoop.mapred.JobConf)1 Test (org.junit.Test)1