break; case DATE: val = "'" + literal.getValueAs(DateString.class).toString() + "'"; type = HiveParser.TOK_DATELITERAL; break; case TIME: val = "'" + literal.getValueAs(TimeString.class).toString() + "'"; type = HiveParser.TOK_TIMESTAMPLITERAL; break; case TIMESTAMP: val = "'" + literal.getValueAs(TimestampString.class).toString() + "'"; type = HiveParser.TOK_TIMESTAMPLITERAL; break; val = "'" + literal.getValueAs(TimestampString.class).toString() + " UTC'"; type = HiveParser.TOK_TIMESTAMPLOCALTZLITERAL; break;
case DATE: return new ExprNodeConstantDesc(TypeInfoFactory.dateTypeInfo, Date.valueOf(literal.getValueAs(DateString.class).toString())); case TIME: return new ExprNodeConstantDesc(TypeInfoFactory.timestampTypeInfo, Timestamp.valueOf(literal.getValueAs(TimeString.class).toString())); case TIMESTAMP: return new ExprNodeConstantDesc(TypeInfoFactory.timestampTypeInfo, Timestamp.valueOf(literal.getValueAs(TimestampString.class).toString())); case TIMESTAMP_WITH_LOCAL_TIME_ZONE: HiveConf conf; TimestampTZUtil.parse(literal.getValueAs(TimestampString.class).toString() + " UTC")); case BINARY: return new ExprNodeConstantDesc(TypeInfoFactory.binaryTypeInfo, literal.getValue3());
public int compare(List<RexLiteral> o1, List<RexLiteral> o2) { final Comparable c1 = o1.get(x).getValueAs(Comparable.class); final Comparable c2 = o2.get(x).getValueAs(Comparable.class); return RelFieldCollation.compare(c1, c2, nullComparison); } };
public int compare(List<RexLiteral> o1, List<RexLiteral> o2) { final Comparable c1 = o1.get(x).getValueAs(Comparable.class); final Comparable c2 = o2.get(x).getValueAs(Comparable.class); return RelFieldCollation.compare(c2, c1, -nullComparison); } };
public int compare(List<RexLiteral> o1, List<RexLiteral> o2) { final Comparable c1 = o1.get(x).getValueAs(Comparable.class); final Comparable c2 = o2.get(x).getValueAs(Comparable.class); return RelFieldCollation.compare(c2, c1, -nullComparison); } };
public int compare(List<RexLiteral> o1, List<RexLiteral> o2) { final Comparable c1 = o1.get(x).getValueAs(Comparable.class); final Comparable c2 = o2.get(x).getValueAs(Comparable.class); return RelFieldCollation.compare(c1, c2, nullComparison); } };
@Override public <T> T getOperandLiteralValue(int ordinal, Class<T> clazz) { final RexNode node = operands.get(ordinal); if (node instanceof RexLiteral) { return ((RexLiteral) node).getValueAs(clazz); } return clazz.cast(RexLiteral.value(node)); }
@Override public <T> T getOperandLiteralValue(int ordinal, Class<T> clazz) { final RexNode node = operands.get(ordinal); if (node instanceof RexLiteral) { return ((RexLiteral) node).getValueAs(clazz); } return clazz.cast(RexLiteral.value(node)); }
public Object execute(Context context) { switch (node.getKind()) { case LITERAL: return ((RexLiteral) node).getValueAs(Comparable.class); case INPUT_REF: return context.values[((RexInputRef) node).getIndex()]; default: throw new RuntimeException("unknown expression type " + node); } } };
public Object execute(Context context) { switch (node.getKind()) { case LITERAL: return ((RexLiteral) node).getValueAs(Comparable.class); case INPUT_REF: return context.values[((RexInputRef) node).getIndex()]; default: throw new RuntimeException("unknown expression type " + node); } } };
@Override public String visitCall(RexCall call) { if (call.op == SqlStdOperatorTable.ITEM) { return ((RexLiteral) call.getOperands().get(1)).getValueAs(String.class); } return super.visitCall(call); } }
/** * Returns the selectivity value stored in a call. * * @param artificialSelectivityFuncNode Call containing the selectivity value * @return selectivity value */ public static double getSelectivityValue( RexNode artificialSelectivityFuncNode) { assert artificialSelectivityFuncNode instanceof RexCall; RexCall call = (RexCall) artificialSelectivityFuncNode; assert call.getOperator() == ARTIFICIAL_SELECTIVITY_FUNC; RexNode operand = call.getOperands().get(0); return ((RexLiteral) operand).getValueAs(Double.class); }
private void checkBigDecimalLiteral(RexBuilder builder, String val) { final RexLiteral literal = builder.makeExactLiteral(new BigDecimal(val)); assertThat("builder.makeExactLiteral(new BigDecimal(" + val + ")).getValueAs(BigDecimal.class).toString()", literal.getValueAs(BigDecimal.class).toString(), is(val)); }
@Override public void implement(Implementor implementor) { implementor.visitChild(0, getInput()); final List<RelDataTypeField> fields = getRowType().getFieldList(); for (RelFieldCollation fieldCollation : collation.getFieldCollations()) { final String name = fields.get(fieldCollation.getFieldIndex()).getName(); implementor.addSort(name, fieldCollation.getDirection()); } if (offset != null) { implementor.offset(((RexLiteral) offset).getValueAs(Long.class)); } if (fetch != null) { implementor.fetch(((RexLiteral) fetch).getValueAs(Long.class)); } }
private void checkTimestamp(RexNode node) { assertThat(node.toString(), is("1969-07-21 02:56:15")); RexLiteral literal = (RexLiteral) node; assertThat(literal.getValue() instanceof Calendar, is(true)); assertThat(literal.getValue2() instanceof Long, is(true)); assertThat(literal.getValue3() instanceof Long, is(true)); assertThat((Long) literal.getValue2(), is(MOON)); assertThat(literal.getValueAs(Calendar.class), notNullValue()); assertThat(literal.getValueAs(TimestampString.class), notNullValue()); }
private void checkTime(RexNode node) { assertThat(node.toString(), is("02:56:15")); RexLiteral literal = (RexLiteral) node; assertThat(literal.getValue() instanceof Calendar, is(true)); assertThat(literal.getValue2() instanceof Integer, is(true)); assertThat(literal.getValue3() instanceof Integer, is(true)); assertThat((Integer) literal.getValue2(), is(MOON_TIME)); assertThat(literal.getValueAs(Calendar.class), notNullValue()); assertThat(literal.getValueAs(TimeString.class), notNullValue()); }
private void checkTimestamp(RexNode node) { assertThat(node.toString(), is("1969-07-21 02:56:15")); RexLiteral literal = (RexLiteral) node; assertThat(literal.getValue() instanceof Calendar, is(true)); assertThat(literal.getValue2() instanceof Long, is(true)); assertThat(literal.getValue3() instanceof Long, is(true)); assertThat((Long) literal.getValue2(), is(MOON)); assertThat(literal.getValueAs(Calendar.class), notNullValue()); assertThat(literal.getValueAs(TimestampString.class), notNullValue()); }
private void checkDate(RexNode node) { assertThat(node.toString(), is("1969-07-21")); RexLiteral literal = (RexLiteral) node; assertThat(literal.getValue() instanceof Calendar, is(true)); assertThat(literal.getValue2() instanceof Integer, is(true)); assertThat(literal.getValue3() instanceof Integer, is(true)); assertThat((Integer) literal.getValue2(), is(MOON_DAY)); assertThat(literal.getValueAs(Calendar.class), notNullValue()); assertThat(literal.getValueAs(DateString.class), notNullValue()); }
private void checkTime(RexNode node) { assertThat(node.toString(), is("02:56:15")); RexLiteral literal = (RexLiteral) node; assertThat(literal.getValue() instanceof Calendar, is(true)); assertThat(literal.getValue2() instanceof Integer, is(true)); assertThat(literal.getValue3() instanceof Integer, is(true)); assertThat((Integer) literal.getValue2(), is(MOON_TIME)); assertThat(literal.getValueAs(Calendar.class), notNullValue()); assertThat(literal.getValueAs(TimeString.class), notNullValue()); }
private void checkDate(RexNode node) { assertThat(node.toString(), is("1969-07-21")); RexLiteral literal = (RexLiteral) node; assertThat(literal.getValue() instanceof Calendar, is(true)); assertThat(literal.getValue2() instanceof Integer, is(true)); assertThat(literal.getValue3() instanceof Integer, is(true)); assertThat((Integer) literal.getValue2(), is(MOON_DAY)); assertThat(literal.getValueAs(Calendar.class), notNullValue()); assertThat(literal.getValueAs(DateString.class), notNullValue()); }