Java Code Examples for org.apache.calcite.rex.RexLiteral#toString()
The following examples show how to use
org.apache.calcite.rex.RexLiteral#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RexToTestCodeShuttle.java From calcite with Apache License 2.0 | 6 votes |
@Override public String visitLiteral(RexLiteral literal) { RelDataType type = literal.getType(); if (type.getSqlTypeName() == SqlTypeName.BOOLEAN) { if (literal.isNull()) { return "nullBool"; } return literal.toString() + "Literal"; } if (type.getSqlTypeName() == SqlTypeName.INTEGER) { if (literal.isNull()) { return "nullInt"; } return "literal(" + literal.getValue() + ")"; } if (type.getSqlTypeName() == SqlTypeName.VARCHAR) { if (literal.isNull()) { return "nullVarchar"; } } return "/*" + literal.getTypeName().getName() + "*/" + literal.toString(); }
Example 2
Source File: ProjectAnalyzer.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public FunctionRender visitLiteral(RexLiteral literal) { if (!renderer.isScriptsEnabled()) { throw UserException.permissionError().message("Scripts must be enabled to allow for complex expression pushdowns.").build(logger); } requiresScripts = true; switch (literal.getType().getSqlTypeName()) { case INTERVAL_YEAR: case INTERVAL_YEAR_MONTH: case INTERVAL_MONTH: case INTERVAL_DAY: case INTERVAL_DAY_HOUR: case INTERVAL_DAY_MINUTE: case INTERVAL_DAY_SECOND: case INTERVAL_HOUR: case INTERVAL_HOUR_MINUTE: case INTERVAL_HOUR_SECOND: case INTERVAL_MINUTE: case INTERVAL_MINUTE_SECOND: case INTERVAL_SECOND: throw UserException.unsupportedError().message("Intervals are not allowed for complex expression pushdowns.").build(logger); case BIGINT: return new FunctionRender(literal.toString() + "L", ImmutableList.<NullReference>of()); case DOUBLE: return new FunctionRender(literal.toString() + "D", ImmutableList.<NullReference>of()); case DATE: case TIME: case TIMESTAMP: return new FunctionRender("Instant.ofEpochMilli(" + Long.toString(((Calendar) literal.getValue()).getTimeInMillis()) + "L)", ImmutableList.of()); default: return new FunctionRender(literal.toString(), ImmutableList.<NullReference>of()); } }