patternStr = pattern.getValue().toString(); } else if (pattern.getTypeName() == SqlTypeName.CHAR) { patternStr = pattern.getValue2().toString(); patternStr = pattern.getValue().toString(); } else if (pattern.getTypeName() == SqlTypeName.CHAR) { patternStr = pattern.getValue2().toString(); escapeStr = escape.getValue().toString(); } else if (escape.getTypeName() == SqlTypeName.CHAR) { escapeStr = escape.getValue2().toString();
private static Object literalValue(RexLiteral literal) { return literal.getValue2(); }
private void convertLimitToASTNode(HiveSort limit) { if (limit != null) { HiveSort hiveLimit = limit; RexNode limitExpr = hiveLimit.getFetchExpr(); if (limitExpr != null) { Object val = ((RexLiteral) limitExpr).getValue2(); hiveAST.limit = ASTBuilder.limit(val); } } }
private static boolean isLimit0(RexNode fetch) { if (fetch != null && fetch.isA(SqlKind.LITERAL)) { RexLiteral l = (RexLiteral) fetch; switch (l.getTypeName()) { case BIGINT: case INTEGER: case DECIMAL: if (((long) l.getValue2()) == 0) { return true; } } } return false; }
@Override public Void visitCall(RexCall call) { if (call.getOperator() == RexBuilder.GET_OPERATOR) { RexLiteral literal = (RexLiteral) call.getOperands().get(1); extraFields.add( new RelDataTypeFieldImpl( (String) literal.getValue2(), -1, call.getType())); } return super.visitCall(call); } }
@Override public Void visitCall(RexCall call) { if (call.getOperator() == RexBuilder.GET_OPERATOR) { RexLiteral literal = (RexLiteral) call.getOperands().get(1); extraFields.add( new RelDataTypeFieldImpl( (String) literal.getValue2(), -1, call.getType())); } return super.visitCall(call); } }
@Override public RexNode visitCall(RexCall call) { if (call.getOperator() == RexBuilder.GET_OPERATOR) { final String name = (String) ((RexLiteral) call.getOperands().get(1)).getValue2(); final int i = lookup(fields, name); if (i >= 0) { return RexInputRef.of(i, fields); } } return super.visitCall(call); }
@Override public RexNode visitCall(RexCall call) { if (call.getOperator() == RexBuilder.GET_OPERATOR) { final String name = (String) ((RexLiteral) call.getOperands().get(1)).getValue2(); final int i = lookup(fields, name); if (i >= 0) { return RexInputRef.of(i, fields); } } return super.visitCall(call); }
@Test public void testConstant() throws Exception { check((rexBuilder, executor) -> { final List<RexNode> reducedValues = new ArrayList<>(); final RexLiteral ten = rexBuilder.makeExactLiteral(BigDecimal.TEN); executor.reduce(rexBuilder, ImmutableList.of(ten), reducedValues); assertThat(reducedValues.size(), equalTo(1)); assertThat(reducedValues.get(0), instanceOf(RexLiteral.class)); assertThat(((RexLiteral) reducedValues.get(0)).getValue2(), equalTo((Object) 10L)); }); }
@Test public void testConstant() throws Exception { check((rexBuilder, executor) -> { final List<RexNode> reducedValues = new ArrayList<>(); final RexLiteral ten = rexBuilder.makeExactLiteral(BigDecimal.TEN); executor.reduce(rexBuilder, ImmutableList.of(ten), reducedValues); assertThat(reducedValues.size(), equalTo(1)); assertThat(reducedValues.get(0), instanceOf(RexLiteral.class)); assertThat(((RexLiteral) reducedValues.get(0)).getValue2(), equalTo((Object) 10L)); }); }
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 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 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()); }
private void checkTimestampWithLocalTimeZone(RexNode node) { assertThat(node.toString(), is("1969-07-21 02:56:15")); RexLiteral literal = (RexLiteral) node; assertThat(literal.getValue() instanceof TimestampString, is(true)); assertThat(literal.getValue2() instanceof Long, is(true)); assertThat(literal.getValue3() instanceof Long, is(true)); }
private void checkTimestampWithLocalTimeZone(RexNode node) { assertThat(node.toString(), is("1969-07-21 02:56:15")); RexLiteral literal = (RexLiteral) node; assertThat(literal.getValue() instanceof TimestampString, is(true)); assertThat(literal.getValue2() instanceof Long, is(true)); assertThat(literal.getValue3() instanceof Long, is(true)); }