Search in sources :

Example 1 with FilterVarCharScalarGreaterStringGroupColumn

use of org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterVarCharScalarGreaterStringGroupColumn in project hive by apache.

the class TestVectorStringExpressions method testVarCharScalarCompareStringCol.

@Test
public // Test VARCHAR literal to string column comparison
void testVarCharScalarCompareStringCol() throws HiveException {
    VectorizedRowBatch batch = makeStringBatch();
    VectorExpression expr;
    expr = new FilterVarCharScalarEqualStringGroupColumn(new HiveVarchar(new String(red2), 8).getValue().getBytes(), 0);
    expr.evaluate(batch);
    // only red qualifies, and it's in entry 0
    Assert.assertTrue(batch.size == 1);
    Assert.assertTrue(batch.selected[0] == 0);
    batch = makeStringBatch();
    expr = new FilterVarCharScalarGreaterStringGroupColumn(new HiveVarchar(new String(red2), 8).getValue().getBytes(), 0);
    expr.evaluate(batch);
    // only green qualifies, and it's in entry 1
    Assert.assertTrue(batch.size == 1);
    Assert.assertTrue(batch.selected[0] == 1);
    batch = makeStringBatch();
    expr = new FilterVarCharScalarLessEqualStringGroupColumn(new HiveVarchar(new String(green), 10).getValue().getBytes(), 0);
    expr.evaluate(batch);
    // green and red qualify
    Assert.assertTrue(batch.size == 2);
    Assert.assertTrue(batch.selected[0] == 0);
    Assert.assertTrue(batch.selected[1] == 1);
}
Also used : FilterVarCharScalarEqualStringGroupColumn(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterVarCharScalarEqualStringGroupColumn) VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) FilterVarCharScalarGreaterStringGroupColumn(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterVarCharScalarGreaterStringGroupColumn) HiveVarchar(org.apache.hadoop.hive.common.type.HiveVarchar) FilterVarCharScalarLessEqualStringGroupColumn(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterVarCharScalarLessEqualStringGroupColumn) Test(org.junit.Test)

Aggregations

HiveVarchar (org.apache.hadoop.hive.common.type.HiveVarchar)1 VectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch)1 FilterVarCharScalarEqualStringGroupColumn (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterVarCharScalarEqualStringGroupColumn)1 FilterVarCharScalarGreaterStringGroupColumn (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterVarCharScalarGreaterStringGroupColumn)1 FilterVarCharScalarLessEqualStringGroupColumn (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterVarCharScalarLessEqualStringGroupColumn)1 Test (org.junit.Test)1