Search in sources :

Example 26 with PTFExpressionDef

use of org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef in project hive by apache.

the class TestValueBoundaryScanner method testTimestampEquals.

@Test
public void testTimestampEquals() {
    PTFExpressionDef argDef = new PTFExpressionDef();
    argDef.setOI(PrimitiveObjectInspectorFactory.writableTimestampObjectInspector);
    TimestampValueBoundaryScanner scanner = new TimestampValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
    Timestamp ts = new Timestamp();
    ts.setTimeInMillis(1000);
    TimestampWritableV2 w1 = new TimestampWritableV2(ts);
    TimestampWritableV2 w2 = new TimestampWritableV2(ts);
    // empty
    TimestampWritableV2 w3 = new TimestampWritableV2();
    Assert.assertTrue(scanner.isEqual(w1, w2));
    Assert.assertTrue(scanner.isEqual(w2, w1));
    // empty == epoch
    Assert.assertTrue(scanner.isEqual(w3, new TimestampWritableV2(new Timestamp())));
    // empty != another non-epoch
    Assert.assertFalse(scanner.isEqual(w3, w1));
    Assert.assertFalse(scanner.isEqual(null, w2));
    Assert.assertFalse(scanner.isEqual(w1, null));
    Assert.assertTrue(scanner.isEqual(null, null));
}
Also used : PTFExpressionDef(org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef) Timestamp(org.apache.hadoop.hive.common.type.Timestamp) TimestampWritableV2(org.apache.hadoop.hive.serde2.io.TimestampWritableV2) OrderExpressionDef(org.apache.hadoop.hive.ql.plan.ptf.OrderExpressionDef) Test(org.junit.Test)

Aggregations

PTFExpressionDef (org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef)26 OrderExpressionDef (org.apache.hadoop.hive.ql.plan.ptf.OrderExpressionDef)12 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)6 WindowFunctionDef (org.apache.hadoop.hive.ql.plan.ptf.WindowFunctionDef)6 StructObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector)6 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)5 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)5 ShapeDetails (org.apache.hadoop.hive.ql.plan.ptf.ShapeDetails)4 ListObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector)4 WindowFrameDef (org.apache.hadoop.hive.ql.plan.ptf.WindowFrameDef)3 GenericUDAFEvaluator (org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator)3 TableFunctionEvaluator (org.apache.hadoop.hive.ql.udf.ptf.TableFunctionEvaluator)3 WindowingTableFunctionResolver (org.apache.hadoop.hive.ql.udf.ptf.WindowingTableFunction.WindowingTableFunctionResolver)3 Timestamp (org.apache.hadoop.hive.common.type.Timestamp)2 SQLCheckConstraint (org.apache.hadoop.hive.metastore.api.SQLCheckConstraint)2 SQLDefaultConstraint (org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint)2 SQLNotNullConstraint (org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint)2 SQLUniqueConstraint (org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint)2