Examples of DateWritable


Examples of org.apache.hadoop.hive.serde2.io.DateWritable

      Timestamp ts = ((TimestampWritable) timestampConverter.convert(arguments[0].get()))
          .getTimestamp();
      output.set(formatter.format(ts));
      break;
    case DATE:
      DateWritable dw = (DateWritable) dateWritableConverter.convert(arguments[0].get());
      output.set(formatter.format(dw.get()));
      break;
    default:
      throw new UDFArgumentException(
          "TO_DATE() only takes STRING/TIMESTAMP/DATEWRITABLE types, got " + inputType);
    }
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.DateWritable

    DateStatisticsImpl(OrcProto.ColumnStatistics stats) {
      super(stats);
      OrcProto.DateStatistics dateStats = stats.getDateStatistics();
      // min,max values serialized/deserialized as int (days since epoch)
      if (dateStats.hasMaximum()) {
        maximum = new DateWritable(dateStats.getMaximum());
      }
      if (dateStats.hasMinimum()) {
        minimum = new DateWritable(dateStats.getMinimum());
      }
    }
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.DateWritable

    @Override
    void write(Object obj) throws IOException {
      super.write(obj);
      if (obj != null) {
        // Using the Writable here as it's used directly for writing as well as for stats.
        DateWritable val = ((DateObjectInspector) inspector).getPrimitiveWritableObject(obj);
        indexStatistics.updateDate(val);
        writer.write(val.getDays());
      }
    }
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.DateWritable

  @Test
  public void testBuilderComplexTypes() throws Exception {
    SearchArgument sarg =
        SearchArgument.FACTORY.newBuilder()
            .startAnd()
              .lessThan("x", new DateWritable(10))
              .lessThanEquals("y", new HiveChar("hi", 10))
              .equals("z", HiveDecimal.create("1.0"))
            .end()
            .build();
    assertEquals("leaf-0 = (LESS_THAN x 1970-01-11)\n" +
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.DateWritable

    ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
    ObjectInspector[] arguments = {valueOI1, valueOI2};


    udf.initialize(arguments);
    DeferredObject valueObj1 = new DeferredJavaObject(new DateWritable(new Date(109, 06, 20)));
    DeferredObject valueObj2 = new DeferredJavaObject(new Integer("4"));
    DeferredObject[] args = {valueObj1, valueObj2};
    Text output = (Text) udf.evaluate(args);

    assertEquals("date_sub() test for DATEWRITABLE failed ", "2009-07-16", output.toString());
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.DateWritable

    ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
    ObjectInspector[] arguments = {valueOI1, valueOI2};


    udf.initialize(arguments);
    DeferredObject valueObj1 = new DeferredJavaObject(new DateWritable(new Date(109, 06, 20)));
    DeferredObject valueObj2 = new DeferredJavaObject(new DateWritable(new Date(109, 06, 10)));
    DeferredObject[] args = {valueObj1, valueObj2};
    IntWritable output = (IntWritable) udf.evaluate(args);

    assertEquals("datediff() test for DATEWRITABLE failed ", "10", output.toString());
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.DateWritable

    Map<String, String> partSpec = new HashMap<String, String>();
    partSpec.put(colName, originalColSpec);
    BaseSemanticAnalyzer.normalizeColSpec(partSpec, colName, colType, originalColSpec, colValue);
    assertEquals(result, partSpec.get(colName));
    if (colValue instanceof Date) {
      DateWritable dw = new DateWritable((Date)colValue);
      BaseSemanticAnalyzer.normalizeColSpec(partSpec, colName, colType, originalColSpec, dw);
      assertEquals(result, partSpec.get(colName));
    }
  }
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.DateWritable

    GenericUDFDate udf = new GenericUDFDate();
    ObjectInspector valueOI = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
    ObjectInspector[] arguments = {valueOI};

    udf.initialize(arguments);
    DeferredObject valueObj = new DeferredJavaObject(new DateWritable(new Date(109, 06, 30)));
    DeferredObject[] args = {valueObj};
    Text output = (Text) udf.evaluate(args);

    assertEquals("to_date() test for DATEWRITABLE failed ", "2009-07-30", output.toString());
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.DateWritable

    ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
    ObjectInspector[] arguments = {valueOI1, valueOI2};


    udf.initialize(arguments);
    DeferredObject valueObj1 = new DeferredJavaObject(new DateWritable(new Date(109, 06, 20)));
    DeferredObject valueObj2 = new DeferredJavaObject(new Integer("4"));
    DeferredObject[] args = {valueObj1, valueObj2};
    Text output = (Text) udf.evaluate(args);

    assertEquals("date_add() test for DATEWRITABLE failed ", "2009-07-24", output.toString());
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.io.DateWritable

            continue;
          }

          // Dates are stored as long, so convert and compare
          if (a instanceof DateWritable) {
            DateWritable adt = (DateWritable) a;
            Assert.assertEquals(adt.get().getTime(), DateWritable.daysToMillis((int) ((LongWritable) b).get()));
            continue;
          }

          // Decimals are stored as BigInteger, so convert and compare
          if (a instanceof HiveDecimalWritable) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.