Refine search
@Override public String toString() { return intervalValue.toString(); } }
@Override protected HiveIntervalYearMonth getIntervalYearMonth(String arg) { return HiveIntervalYearMonth.valueOf(arg); } }
public IntervalYearMonthColAddDateColumn(int colNum1, int colNum2, int outputColumn) { this.colNum1 = colNum1; this.colNum2 = colNum2; this.outputColumn = outputColumn; scratchIntervalYearMonth1 = new HiveIntervalYearMonth(); scratchDate2 = new Date(0); outputDate = new Date(0); }
public HiveIntervalYearMonth add(HiveIntervalYearMonth left, HiveIntervalYearMonth right) { HiveIntervalYearMonth result = null; if (left == null || right == null) { return null; } result = new HiveIntervalYearMonth(left.getTotalMonths() + right.getTotalMonths()); return result; }
public void set(HiveIntervalYearMonth other) { set(other.getTotalMonths()); }
private void evaluate(LongColumnVector outputColVector, BytesColumnVector inputColVector, int i) { try { HiveIntervalYearMonth interval = HiveIntervalYearMonth.valueOf( new String(inputColVector.vector[i], inputColVector.start[i], inputColVector.length[i], "UTF-8")); outputColVector.vector[i] = interval.getTotalMonths(); } catch (Exception e) { outputColVector.vector[i] = 1; outputColVector.isNull[i] = true; outputColVector.noNulls = false; } }
public DateScalarSubtractIntervalYearMonthColumn(long value, int colNum, int outputColumn) { this.colNum = colNum; this.value = new Date(DateWritable.daysToMillis((int) value)); this.outputColumn = outputColumn; scratchIntervalYearMonth2 = new HiveIntervalYearMonth(); outputDate = new Date(0); }
case DATE: return new ExprNodeConstantDesc(TypeInfoFactory.dateTypeInfo, new Date(((Calendar)literal.getValue()).getTimeInMillis())); case TIME: case TIMESTAMP: { BigDecimal monthsBd = (BigDecimal) literal.getValue(); return new ExprNodeConstantDesc(TypeInfoFactory.intervalYearMonthTypeInfo, new HiveIntervalYearMonth(monthsBd.intValue())); new HiveIntervalDayTime(secsBd));
@Deprecated public boolean add(java.sql.Date dt, HiveIntervalYearMonth interval, java.sql.Date result) { if (dt == null || interval == null) { return false; } long resultMillis = addMonthsToMillis(dt.getTime(), interval.getTotalMonths()); result.setTime(resultMillis); return true; }
scratchDate1.setTime(DateWritable.daysToMillis((int) vector1[0])); scratchIntervalYearMonth2.set((int) vector2[0]); dtm.add( scratchDate1, scratchIntervalYearMonth2, outputDate); outputVector[0] = DateWritable.dateToDays(outputDate); } else if (inputColVector1.isRepeating) { scratchDate1.setTime(DateWritable.daysToMillis((int) vector1[0])); if (batch.selectedInUse) { for(int j = 0; j != n; j++) { int i = sel[j]; scratchIntervalYearMonth2.set((int) vector2[i]); dtm.add( scratchDate1, scratchIntervalYearMonth2, outputDate); scratchIntervalYearMonth2.set((int) vector2[i]); dtm.add( scratchDate1, scratchIntervalYearMonth2, outputDate); for(int j = 0; j != n; j++) { int i = sel[j]; scratchDate1.setTime(DateWritable.daysToMillis((int) vector1[i])); scratchIntervalYearMonth2.set((int) vector2[i]); dtm.add( scratchDate1, scratchIntervalYearMonth2, outputDate); scratchIntervalYearMonth2.set((int) vector2[i]); dtm.add( scratchDate1, scratchIntervalYearMonth2, outputDate);
type = HiveParser.TOK_INTERVAL_YEAR_MONTH_LITERAL; BigDecimal monthsBd = (BigDecimal) literal.getValue(); HiveIntervalYearMonth intervalYearMonth = new HiveIntervalYearMonth(monthsBd.intValue()); val = "'" + intervalYearMonth.toString() + "'"; HiveIntervalDayTime intervalDayTime = new HiveIntervalDayTime(secsBd); val = "'" + intervalDayTime.toString() + "'";
case HiveParser.TOK_INTERVAL_YEAR_MONTH_LITERAL: return new ExprNodeConstantDesc(TypeInfoFactory.intervalYearMonthTypeInfo, HiveIntervalYearMonth.valueOf(intervalString)); case HiveParser.TOK_INTERVAL_DAY_TIME_LITERAL: return new ExprNodeConstantDesc(TypeInfoFactory.intervalDayTimeTypeInfo, HiveIntervalDayTime.valueOf(intervalString)); case HiveParser.TOK_INTERVAL_YEAR_LITERAL: return new ExprNodeConstantDesc(TypeInfoFactory.intervalYearMonthTypeInfo, new HiveIntervalYearMonth(Integer.parseInt(intervalString), 0)); case HiveParser.TOK_INTERVAL_MONTH_LITERAL: return new ExprNodeConstantDesc(TypeInfoFactory.intervalYearMonthTypeInfo, new HiveIntervalYearMonth(0, Integer.parseInt(intervalString))); case HiveParser.TOK_INTERVAL_DAY_LITERAL: return new ExprNodeConstantDesc(TypeInfoFactory.intervalDayTimeTypeInfo, new HiveIntervalDayTime(Integer.parseInt(intervalString), 0, 0, 0, 0)); case HiveParser.TOK_INTERVAL_HOUR_LITERAL: return new ExprNodeConstantDesc(TypeInfoFactory.intervalDayTimeTypeInfo,
if (!value.equals(expected)) { TestCase.fail("HiveIntervalYearMonth field mismatch (expected " + expected.toString() + " found " + value.toString() + ")"); if (!value.equals(expected)) { TestCase.fail("HiveIntervalDayTime field mismatch (expected " + expected.toString() + " found " + value.toString() + ")");
@Test @Concurrent(count=4) @Repeating(repetition=100) public void testNormalize() throws Exception { HiveIntervalYearMonth i1 = new HiveIntervalYearMonth(1, -6); assertEquals(HiveIntervalYearMonth.valueOf("0-6"), i1); assertEquals(0, i1.getYears()); assertEquals(6, i1.getMonths()); assertEquals(HiveIntervalYearMonth.valueOf("0-0"), new HiveIntervalYearMonth(0, 0)); assertEquals(HiveIntervalYearMonth.valueOf("0-0"), new HiveIntervalYearMonth(-1, 12)); assertEquals(HiveIntervalYearMonth.valueOf("0-4"), new HiveIntervalYearMonth(-1, 16)); assertEquals(HiveIntervalYearMonth.valueOf("0-11"), new HiveIntervalYearMonth(1, -1)); assertEquals(HiveIntervalYearMonth.valueOf("-0-11"), new HiveIntervalYearMonth(-1, 1)); // -5 years + 121 months = -5 years + 10 years + 1 month = 5 years 1 month assertEquals(HiveIntervalYearMonth.valueOf("5-1"), new HiveIntervalYearMonth(-5, 121)); } }
case INTERVAL_YEAR_MONTH: BigDecimal totalMonths = BigDecimal.valueOf(((HiveIntervalYearMonth) value).getTotalMonths()); calciteLiteral = rexBuilder.makeIntervalLiteral(totalMonths, new SqlIntervalQualifier(TimeUnit.YEAR, TimeUnit.MONTH, new SqlParserPos(1,1))); .valueOf(((HiveIntervalDayTime) value).getTotalSeconds() * 1000); value).getNanos(), 6); calciteLiteral = rexBuilder.makeIntervalLiteral(secsValueBd.add(nanosValueBd),
private Object getVectorTypeScalarValue(ExprNodeConstantDesc constDesc) throws HiveException { String t = constDesc.getTypeInfo().getTypeName(); VectorExpression.Type type = VectorExpression.Type.getValue(t); Object scalarValue = getScalarValue(constDesc); switch (type) { case DATE: return new Long(DateWritable.dateToDays((Date) scalarValue)); case INTERVAL_YEAR_MONTH: return ((HiveIntervalYearMonth) scalarValue).getTotalMonths(); default: return scalarValue; } }
scratchIntervalYearMonth2.set((int) vector2[0]); dtm.add( value, scratchIntervalYearMonth2, outputDate); outputVector[0] = DateWritable.dateToDays(outputDate); for(int j = 0; j != n; j++) { int i = sel[j]; scratchIntervalYearMonth2.set((int) vector2[i]); dtm.add( value, scratchIntervalYearMonth2, outputDate); outputVector[i] = DateWritable.dateToDays(outputDate); scratchIntervalYearMonth2.set((int) vector2[i]); dtm.add( value, scratchIntervalYearMonth2, outputDate); outputVector[i] = DateWritable.dateToDays(outputDate); for(int j = 0; j != n; j++) { int i = sel[j]; scratchIntervalYearMonth2.set((int) vector2[i]); dtm.add( value, scratchIntervalYearMonth2, outputDate); scratchIntervalYearMonth2.set((int) vector2[i]); dtm.add( value, scratchIntervalYearMonth2, outputDate);
@Test @Concurrent(count=4) @Repeating(repetition=100) public void testToString() throws Exception { assertEquals("0-0", HiveIntervalYearMonth.valueOf("0-0").toString()); assertEquals("1-2", HiveIntervalYearMonth.valueOf("1-2").toString()); assertEquals("-1-2", HiveIntervalYearMonth.valueOf("-1-2").toString()); assertEquals("1-0", HiveIntervalYearMonth.valueOf("1-0").toString()); assertEquals("-1-0", HiveIntervalYearMonth.valueOf("-1-0").toString()); assertEquals("0-0", HiveIntervalYearMonth.valueOf("-0-0").toString()); }
@Test @Concurrent(count=4) @Repeating(repetition=100) public void testCompare() throws Exception { HiveIntervalYearMonth i1 = new HiveIntervalYearMonth(1, 2); HiveIntervalYearMonth i2 = new HiveIntervalYearMonth(1, 2); HiveIntervalYearMonth i3 = new HiveIntervalYearMonth(1, 3); // compareTo() assertEquals(i1 + " compareTo " + i1, 0, i1.compareTo(i1)); assertEquals(i1 + " compareTo " + i2, 0, i1.compareTo(i2)); assertEquals(i2 + " compareTo " + i1, 0, i2.compareTo(i1)); assertEquals(i3 + " compareTo " + i3, 0, i3.compareTo(i3)); assertTrue(i1 + " compareTo " + i3, 0 > i1.compareTo(i3)); assertTrue(i3 + " compareTo " + i1, 0 < i3.compareTo(i1)); // equals() assertTrue(i1 + " equals " + i1, i1.equals(i1)); assertTrue(i1 + " equals " + i2, i1.equals(i2)); assertFalse(i1 + " equals " + i3, i1.equals(i3)); assertFalse(i3 + " equals " + i1, i3.equals(i1)); // hashCode() assertEquals(i1 + " hashCode " + i1, i1.hashCode(), i1.hashCode()); assertEquals(i1 + " hashCode " + i1, i1.hashCode(), i2.hashCode()); }