org.apache.hadoop.hive.common.type.Date.of()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(225)

本文整理了Java中org.apache.hadoop.hive.common.type.Date.of()方法的一些代码示例,展示了Date.of()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Date.of()方法的具体详情如下:
包路径:org.apache.hadoop.hive.common.type.Date
类名称:Date
方法名:of

Date.of介绍

暂无

代码示例

代码示例来源:origin: apache/hive

@Override
Date transform(final Date value) {
 int actualMonthValue = maskedMonthValue + 1;
 int year  = maskedYearValue  == UNMASKED_VAL ? value.getYear()  : maskedYearValue;
 int month = maskedMonthValue == UNMASKED_VAL ? value.getMonth() : actualMonthValue;
 int day   = maskedDayValue   == UNMASKED_VAL ? value.getDay()  : maskedDayValue;
 return Date.of(year, month, day);
}

代码示例来源:origin: apache/hive

new DateWritableV2(Date.of(2015, 5, 26)),
asList(new IntWritable(1), new IntWritable(3),
  new IntWritable(2), new IntWritable(4)));
new DateWritableV2(Date.of(2015, 5, 26)),
asList(new IntWritable(1), new IntWritable(3),
  new IntWritable(2), new IntWritable(4)));
new DateWritableV2(Date.of(2015, 5, 25)),
asList(new IntWritable(1), new IntWritable(3),
  new IntWritable(2), new IntWritable(5)));
new DateWritableV2(Date.of(2015, 5, 25)),
asList(new IntWritable(1), new IntWritable(3),
  new IntWritable(2), new IntWritable(4)));

代码示例来源:origin: apache/hive

return Date.of(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth());
default:
 throw new BackendException("Unexpected HCat type " + type + " for value " + pigObj

代码示例来源:origin: apache/hive

public void testByteDataTypeAsDays() throws HiveException {
 GenericUDFDateAdd udf = new GenericUDFDateAdd();
 ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
 ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.javaByteObjectInspector;
 ObjectInspector[] arguments = {valueOI1, valueOI2};
 udf.initialize(arguments);
 DeferredObject valueObj1 = new DeferredJavaObject(new DateWritableV2(Date.of(109, 06, 20)));
 DeferredObject valueObj2 = new DeferredJavaObject(new Byte("4"));
 DeferredObject[] args = {valueObj1, valueObj2};
 DateWritableV2 output = (DateWritableV2) udf.evaluate(args);
 assertEquals("date_add() test for BYTE failed ", "0109-06-24", output.toString());
}

代码示例来源:origin: apache/hive

public void testByteDataTypeAsDays() throws HiveException {
 GenericUDFDateSub udf = new GenericUDFDateSub();
 ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
 ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.javaByteObjectInspector;
 ObjectInspector[] arguments = {valueOI1, valueOI2};
 udf.initialize(arguments);
 DeferredObject valueObj1 = new DeferredJavaObject(new DateWritableV2(Date.of(109, 06, 20)));
 DeferredObject valueObj2 = new DeferredJavaObject(new Byte("4"));
 DeferredObject[] args = {valueObj1, valueObj2};
 DateWritableV2 output = (DateWritableV2) udf.evaluate(args);
 assertEquals("date_add() test for BYTE failed ", "0109-06-16", output.toString());
}

代码示例来源:origin: apache/hive

public void testShortDataTypeAsDays() throws HiveException {
  GenericUDFDateAdd udf = new GenericUDFDateAdd();
  ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
  ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.javaShortObjectInspector;
  ObjectInspector[] arguments = {valueOI1, valueOI2};

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

  assertEquals("date_add() test for SHORT failed ", "0109-06-24", output.toString());
 }
}

代码示例来源:origin: apache/hive

public void testShortDataTypeAsDays() throws HiveException {
  GenericUDFDateSub udf = new GenericUDFDateSub();
  ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
  ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.javaShortObjectInspector;
  ObjectInspector[] arguments = {valueOI1, valueOI2};

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

  assertEquals("date_add() test for SHORT failed ", "0109-06-16", output.toString());
 }
}

代码示例来源:origin: apache/hive

public void testDateWritablepToDate() throws HiveException {
 GenericUDFDate udf = new GenericUDFDate();
 ObjectInspector valueOI = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
 ObjectInspector[] arguments = {valueOI};
 udf.initialize(arguments);
 DeferredObject valueObj = new DeferredJavaObject(new DateWritableV2(Date.of(109, 06, 30)));
 DeferredObject[] args = {valueObj};
 DateWritableV2 output = (DateWritableV2) udf.evaluate(args);
 assertEquals("to_date() test for DATEWRITABLE failed ", "0109-06-30", output.toString());
 // Try with null args
 DeferredObject[] nullArgs = { new DeferredJavaObject(null) };
 output = (DateWritableV2) udf.evaluate(nullArgs);
 assertNull("to_date() with null DATE", output);
}

代码示例来源:origin: apache/hive

public void testDateWritablepToDate() throws HiveException {
 GenericUDFDateAdd udf = new GenericUDFDateAdd();
 ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
 ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
 ObjectInspector[] arguments = {valueOI1, valueOI2};
 udf.initialize(arguments);
 DeferredObject valueObj1 = new DeferredJavaObject(new DateWritableV2(Date.of(109, 06, 20)));
 DeferredObject valueObj2 = new DeferredJavaObject(new Integer("4"));
 DeferredObject[] args = {valueObj1, valueObj2};
 DateWritableV2 output = (DateWritableV2) udf.evaluate(args);
 assertEquals("date_add() test for DATEWRITABLE failed ", "0109-06-24", output.toString());
 // Test with null args
 args = new DeferredObject[] { new DeferredJavaObject(null), valueObj2 };
 assertNull("date_add() 1st arg null", udf.evaluate(args));
 args = new DeferredObject[] { valueObj1, new DeferredJavaObject(null) };
 assertNull("date_add() 2nd arg null", udf.evaluate(args));
 args = new DeferredObject[] { new DeferredJavaObject(null), new DeferredJavaObject(null) };
 assertNull("date_add() both args null", udf.evaluate(args));
}

代码示例来源:origin: apache/hive

public void testDateWritablepToDate() throws HiveException {
 GenericUDFDateSub udf = new GenericUDFDateSub();
 ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
 ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
 ObjectInspector[] arguments = {valueOI1, valueOI2};
 udf.initialize(arguments);
 DeferredObject valueObj1 = new DeferredJavaObject(new DateWritableV2(Date.of(109, 06, 20)));
 DeferredObject valueObj2 = new DeferredJavaObject(new Integer("4"));
 DeferredObject[] args = {valueObj1, valueObj2};
 DateWritableV2 output = (DateWritableV2) udf.evaluate(args);
 assertEquals("date_sub() test for DATEWRITABLE failed ", "0109-06-16", output.toString());
 // Test with null args
 args = new DeferredObject[] { new DeferredJavaObject(null), valueObj2 };
 assertNull("date_add() 1st arg null", udf.evaluate(args));
 args = new DeferredObject[] { valueObj1, new DeferredJavaObject(null) };
 assertNull("date_add() 2nd arg null", udf.evaluate(args));
 args = new DeferredObject[] { new DeferredJavaObject(null), new DeferredJavaObject(null) };
 assertNull("date_add() both args null", udf.evaluate(args));
}

代码示例来源:origin: apache/hive

public void testDateWritablepToDate() throws HiveException {
 GenericUDFDateDiff udf = new GenericUDFDateDiff();
 ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
 ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
 ObjectInspector[] arguments = {valueOI1, valueOI2};
 udf.initialize(arguments);
 DeferredObject valueObj1 = new DeferredJavaObject(new DateWritableV2(Date.of(109, 06, 20)));
 DeferredObject valueObj2 = new DeferredJavaObject(new DateWritableV2(Date.of(109, 06, 10)));
 DeferredObject[] args = {valueObj1, valueObj2};
 IntWritable output = (IntWritable) udf.evaluate(args);
 assertEquals("datediff() test for DATEWRITABLE failed ", "10", output.toString());
 // Test with null args
 args = new DeferredObject[] { new DeferredJavaObject(null), valueObj2 };
 assertNull("date_add() 1st arg null", udf.evaluate(args));
 args = new DeferredObject[] { valueObj1, new DeferredJavaObject(null) };
 assertNull("date_add() 2nd arg null", udf.evaluate(args));
 args = new DeferredObject[] { new DeferredJavaObject(null), new DeferredJavaObject(null) };
 assertNull("date_add() both args null", udf.evaluate(args));
}

代码示例来源:origin: apache/hive

+ ms)));
row.setFieldValue(1,
  new DateWritableV2(Date.of(year - 1900, 11, 25)));
writer.addRow(row);
    (Timestamp.valueOf(year + "-05-05 12:34:56." + ms)),
  row.getFieldValue(0));
assertEquals(new DateWritableV2(Date.of(year - 1900, 11, 25)),
  row.getFieldValue(1));

代码示例来源:origin: org.apache.hive.hcatalog/hive-hcatalog-pig-adapter

return Date.of(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth());
default:
 throw new BackendException("Unexpected HCat type " + type + " for value " + pigObj

相关文章