Package org.apache.hadoop.hive.serde2.io

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


        .getTimestamp();
      calendar.setTime(ts);
      calendar.add(Calendar.DAY_OF_MONTH, -toBeSubed.get());
      break;
    case DATE:
      DateWritable dw = (DateWritable) dateWritableConverter.convert(arguments[0].get());
      calendar.setTime(dw.get());
      calendar.add(Calendar.DAY_OF_MONTH, -toBeSubed.get());
      break;
    default:
      throw new UDFArgumentException(
        "DATE_SUB() only takes STRING/TIMESTAMP/DATEWRITABLE types, got " + inputType1);
View Full Code Here


      Timestamp ts = ((TimestampWritable) converter.convert(argument.get()))
        .getTimestamp();
      date.setTime(ts.getTime());
      break;
    case DATE:
      DateWritable dw = (DateWritable) converter.convert(argument.get());
      date = dw.get();
      break;
    default:
      throw new UDFArgumentException(
        "TO_DATE() only takes STRING/TIMESTAMP/DATEWRITABLE types, got " + inputType);
    }
View Full Code Here

      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

    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

    @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

  @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

    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

    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

    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

    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

TOP

Related Classes of org.apache.hadoop.hive.serde2.io.DateWritable

Copyright © 2018 www.massapicom. 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.