case CHAR: case BOOLEAN: if (literal.getValue3() == null) { return ASTBuilder.construct(HiveParser.TOK_NULL, "TOK_NULL").node(); case TINYINT: if (useTypeQualInLiteral) { val = literal.getValue3() + "Y"; } else { val = literal.getValue3(); case SMALLINT: if (useTypeQualInLiteral) { val = literal.getValue3() + "S"; } else { val = literal.getValue3(); val = literal.getValue3(); type = HiveParser.IntegralLiteral; break; case BIGINT: if (useTypeQualInLiteral) { val = literal.getValue3() + "L"; } else { val = literal.getValue3(); val = literal.getValue3() + "D"; type = HiveParser.NumberLiteral; break;
case CHAR: case BOOLEAN: if (literal.getValue3() == null) { return ASTBuilder.construct(HiveParser.TOK_NULL, "TOK_NULL").node(); case TINYINT: if (useTypeQualInLiteral) { val = literal.getValue3() + "Y"; } else { val = literal.getValue3(); case SMALLINT: if (useTypeQualInLiteral) { val = literal.getValue3() + "S"; } else { val = literal.getValue3(); val = literal.getValue3(); type = HiveParser.IntegralLiteral; break; case BIGINT: if (useTypeQualInLiteral) { val = literal.getValue3() + "L"; } else { val = literal.getValue3(); val = literal.getValue3() + "D"; type = HiveParser.NumberLiteral; break;
case TINYINT: return new ExprNodeConstantDesc(TypeInfoFactory.byteTypeInfo, Byte.valueOf(((Number) literal .getValue3()).byteValue())); case SMALLINT: return new ExprNodeConstantDesc(TypeInfoFactory.shortTypeInfo, Short.valueOf(((Number) literal.getValue3()).shortValue())); case INTEGER: return new ExprNodeConstantDesc(TypeInfoFactory.intTypeInfo, Integer.valueOf(((Number) literal.getValue3()).intValue())); case BIGINT: return new ExprNodeConstantDesc(TypeInfoFactory.longTypeInfo, Long.valueOf(((Number) literal .getValue3()).longValue())); case FLOAT: case REAL: return new ExprNodeConstantDesc(TypeInfoFactory.floatTypeInfo, Float.valueOf(((Number) literal.getValue3()).floatValue())); case DOUBLE: return new ExprNodeConstantDesc(TypeInfoFactory.doubleTypeInfo, Double.valueOf(((Number) literal.getValue3()).doubleValue())); case DATE: return new ExprNodeConstantDesc(TypeInfoFactory.dateTypeInfo, case TIME: case TIMESTAMP: { Object value = literal.getValue3(); if (value instanceof Long) { value = new Timestamp((Long)value); return new ExprNodeConstantDesc(TypeInfoFactory.binaryTypeInfo, literal.getValue3());
case TINYINT: return new ExprNodeConstantDesc(TypeInfoFactory.byteTypeInfo, Byte.valueOf(((Number) literal .getValue3()).byteValue())); case SMALLINT: return new ExprNodeConstantDesc(TypeInfoFactory.shortTypeInfo, Short.valueOf(((Number) literal.getValue3()).shortValue())); case INTEGER: return new ExprNodeConstantDesc(TypeInfoFactory.intTypeInfo, Integer.valueOf(((Number) literal.getValue3()).intValue())); case BIGINT: return new ExprNodeConstantDesc(TypeInfoFactory.longTypeInfo, Long.valueOf(((Number) literal .getValue3()).longValue())); case FLOAT: case REAL: return new ExprNodeConstantDesc(TypeInfoFactory.floatTypeInfo, Float.valueOf(((Number) literal.getValue3()).floatValue())); case DOUBLE: return new ExprNodeConstantDesc(TypeInfoFactory.doubleTypeInfo, Double.valueOf(((Number) literal.getValue3()).doubleValue())); case DATE: return new ExprNodeConstantDesc(TypeInfoFactory.dateTypeInfo, TimestampTZUtil.parse(literal.getValueAs(TimestampString.class).toString() + " UTC")); case BINARY: return new ExprNodeConstantDesc(TypeInfoFactory.binaryTypeInfo, literal.getValue3()); case DECIMAL: return new ExprNodeConstantDesc(TypeInfoFactory.getDecimalTypeInfo(lType.getPrecision(), lType.getScale()), HiveDecimal.create((BigDecimal)literal.getValue3())); case VARCHAR:
return new LitInput(literal.getValue3().toString(), key, literalFirst);
case TINYINT: return new ExprNodeConstantDesc(TypeInfoFactory.byteTypeInfo, Byte.valueOf(((Number) literal .getValue3()).byteValue())); case SMALLINT: return new ExprNodeConstantDesc(TypeInfoFactory.shortTypeInfo, Short.valueOf(((Number) literal.getValue3()).shortValue())); case INTEGER: return new ExprNodeConstantDesc(TypeInfoFactory.intTypeInfo, Integer.valueOf(((Number) literal.getValue3()).intValue())); case BIGINT: return new ExprNodeConstantDesc(TypeInfoFactory.longTypeInfo, Long.valueOf(((Number) literal .getValue3()).longValue())); case FLOAT: return new ExprNodeConstantDesc(TypeInfoFactory.floatTypeInfo, Float.valueOf(((Number) literal.getValue3()).floatValue())); case DOUBLE: return new ExprNodeConstantDesc(TypeInfoFactory.doubleTypeInfo, Double.valueOf(((Number) literal.getValue3()).doubleValue())); case DATE: return new ExprNodeConstantDesc(TypeInfoFactory.dateTypeInfo, new Date(((Calendar)literal.getValue()).getTimeInMillis())); case TIMESTAMP: { Object value = literal.getValue3(); if (value instanceof Long) { value = new Timestamp((Long)value); return new ExprNodeConstantDesc(TypeInfoFactory.binaryTypeInfo, literal.getValue3()); case DECIMAL: return new ExprNodeConstantDesc(TypeInfoFactory.getDecimalTypeInfo(lType.getPrecision(),
final RexLiteral rexLiteral = (RexLiteral) e; if (!formatDateString) { return Objects.toString(rexLiteral.getValue3()); } else {
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)); }
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()); }
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()); }
/** Test case for * <a href="https://issues.apache.org/jira/browse/CALCITE-2306">[CALCITE-2306] * AssertionError in {@link RexLiteral#getValue3} with null literal of type * DECIMAL</a>. */ @Test public void testDecimalLiteral() { final RelDataTypeFactory typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT); final RelDataType type = typeFactory.createSqlType(SqlTypeName.DECIMAL); final RexBuilder builder = new RexBuilder(typeFactory); final RexLiteral literal = builder.makeExactLiteral(null, type); assertThat(literal.getValue3(), nullValue()); }
/** Test case for * <a href="https://issues.apache.org/jira/browse/CALCITE-2306">[CALCITE-2306] * AssertionError in {@link RexLiteral#getValue3} with null literal of type * DECIMAL</a>. */ @Test public void testDecimalLiteral() { final RelDataTypeFactory typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT); final RelDataType type = typeFactory.createSqlType(SqlTypeName.DECIMAL); final RexBuilder builder = new RexBuilder(typeFactory); final RexLiteral literal = builder.makeExactLiteral(null, type); assertThat(literal.getValue3(), nullValue()); }
rangeQueryInput = new RangeQueryInput(((NlsString) literal.getValue()).getValue(), filter.getKind()); } else { rangeQueryInput = new RangeQueryInput((literal.getValue3().toString()), filter.getKind());