org.apache.calcite.util.NlsString Java Examples
The following examples show how to use
org.apache.calcite.util.NlsString.
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: TupleFilterVisitor.java From kylin with Apache License 2.0 | 6 votes |
@Override public TupleFilter visitLiteral(RexLiteral literal) { String strValue = null; Object literalValue = literal.getValue(); if (literalValue instanceof NlsString) { strValue = ((NlsString) literalValue).getValue(); } else if (literalValue instanceof GregorianCalendar) { GregorianCalendar g = (GregorianCalendar) literalValue; strValue = Long.toString(g.getTimeInMillis()); } else if (literalValue instanceof TimeUnitRange) { // Extract(x from y) in where clause strValue = ((TimeUnitRange) literalValue).name(); } else if (literalValue == null) { strValue = null; } else { strValue = literalValue.toString(); } TupleFilter filter = new ConstantTupleFilter(strValue); return filter; }
Example #2
Source File: TupleFilterVisitor.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Override public TupleFilter visitLiteral(RexLiteral literal) { String strValue = null; Object literalValue = literal.getValue(); if (literalValue instanceof NlsString) { strValue = ((NlsString) literalValue).getValue(); } else if (literalValue instanceof GregorianCalendar) { GregorianCalendar g = (GregorianCalendar) literalValue; strValue = Long.toString(g.getTimeInMillis()); } else if (literalValue instanceof TimeUnitRange) { // Extract(x from y) in where clause strValue = ((TimeUnitRange) literalValue).name(); } else if (literalValue == null) { strValue = null; } else { strValue = literalValue.toString(); } TupleFilter filter = new ConstantTupleFilter(strValue); return filter; }
Example #3
Source File: RexBuilder.java From Bats with Apache License 2.0 | 6 votes |
/** * Creates a RexBuilder. * * @param typeFactory Type factory */ public RexBuilder(RelDataTypeFactory typeFactory) { this.typeFactory = typeFactory; this.booleanTrue = makeLiteral( Boolean.TRUE, typeFactory.createSqlType(SqlTypeName.BOOLEAN), SqlTypeName.BOOLEAN); this.booleanFalse = makeLiteral( Boolean.FALSE, typeFactory.createSqlType(SqlTypeName.BOOLEAN), SqlTypeName.BOOLEAN); this.charEmpty = makeLiteral( new NlsString("", null, null), typeFactory.createSqlType(SqlTypeName.CHAR, 0), SqlTypeName.CHAR); this.constantNull = makeLiteral( null, typeFactory.createSqlType(SqlTypeName.NULL), SqlTypeName.NULL); }
Example #4
Source File: RexBuilder.java From calcite with Apache License 2.0 | 6 votes |
/** * Creates a RexBuilder. * * @param typeFactory Type factory */ public RexBuilder(RelDataTypeFactory typeFactory) { this.typeFactory = typeFactory; this.booleanTrue = makeLiteral( Boolean.TRUE, typeFactory.createSqlType(SqlTypeName.BOOLEAN), SqlTypeName.BOOLEAN); this.booleanFalse = makeLiteral( Boolean.FALSE, typeFactory.createSqlType(SqlTypeName.BOOLEAN), SqlTypeName.BOOLEAN); this.charEmpty = makeLiteral( new NlsString("", null, null), typeFactory.createSqlType(SqlTypeName.CHAR, 0), SqlTypeName.CHAR); this.constantNull = makeLiteral( null, typeFactory.createSqlType(SqlTypeName.NULL), SqlTypeName.NULL); }
Example #5
Source File: SqlUtil.java From Bats with Apache License 2.0 | 6 votes |
/** * Creates the type of an {@link org.apache.calcite.util.NlsString}. * * <p>The type inherits the The NlsString's {@link Charset} and * {@link SqlCollation}, if they are set, otherwise it gets the system * defaults. * * @param typeFactory Type factory * @param str String * @return Type, including collation and charset */ public static RelDataType createNlsStringType( RelDataTypeFactory typeFactory, NlsString str) { Charset charset = str.getCharset(); if (null == charset) { charset = typeFactory.getDefaultCharset(); } SqlCollation collation = str.getCollation(); if (null == collation) { collation = SqlCollation.COERCIBLE; } RelDataType type = typeFactory.createSqlType( SqlTypeName.CHAR, str.getValue().length()); type = typeFactory.createTypeWithCharsetAndCollation( type, charset, collation); return type; }
Example #6
Source File: SqlDatePartOperator.java From dremio-oss with Apache License 2.0 | 6 votes |
@Override public RexNode convertCall(SqlRexContext cx, SqlCall call) { final RexBuilder rexBuilder = cx.getRexBuilder(); final SqlLiteral literal = (SqlLiteral) call.getOperandList().get(0); final String value = ((NlsString)literal.getValue()).getValue(); TimeUnitRange range = VALID_PERIODS.get(value.toLowerCase()); Preconditions.checkNotNull(range, "Unhandle range type: %s.", value); List<RexNode> exprs = new ArrayList<>(); exprs.add(rexBuilder.makeFlag(range)); exprs.add(cx.convertExpression(call.getOperandList().get(1))); RelDataTypeFactory typeFactory = cx.getTypeFactory(); final RelDataType returnType = typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), exprs.get(1).getType().isNullable()); return rexBuilder.makeCall(returnType, SqlStdOperatorTable.EXTRACT, exprs); }
Example #7
Source File: SqlUserDefinedTableMacro.java From Bats with Apache License 2.0 | 6 votes |
private static Object coerce(Object o, RelDataType type) { if (o == null) { return null; } if (!(type instanceof RelDataTypeFactoryImpl.JavaType)) { return null; } final RelDataTypeFactoryImpl.JavaType javaType = (RelDataTypeFactoryImpl.JavaType) type; final Class<?> clazz = javaType.getJavaClass(); //noinspection unchecked if (clazz.isAssignableFrom(o.getClass())) { return o; } if (clazz == String.class && o instanceof NlsString) { return ((NlsString) o).getValue(); } return null; }
Example #8
Source File: SqlUtil.java From calcite with Apache License 2.0 | 6 votes |
/** * Creates the type of an {@link org.apache.calcite.util.NlsString}. * * <p>The type inherits the The NlsString's {@link Charset} and * {@link SqlCollation}, if they are set, otherwise it gets the system * defaults. * * @param typeFactory Type factory * @param str String * @return Type, including collation and charset */ public static RelDataType createNlsStringType( RelDataTypeFactory typeFactory, NlsString str) { Charset charset = str.getCharset(); if (null == charset) { charset = typeFactory.getDefaultCharset(); } SqlCollation collation = str.getCollation(); if (null == collation) { collation = SqlCollation.COERCIBLE; } RelDataType type = typeFactory.createSqlType( SqlTypeName.CHAR, str.getValue().length()); type = typeFactory.createTypeWithCharsetAndCollation( type, charset, collation); return type; }
Example #9
Source File: RelBuilder.java From calcite with Apache License 2.0 | 6 votes |
/** Infers the alias of an expression. * * <p>If the expression was created by {@link #alias}, replaces the expression * in the project list. */ private String inferAlias(List<RexNode> exprList, RexNode expr, int i) { switch (expr.getKind()) { case INPUT_REF: final RexInputRef ref = (RexInputRef) expr; return stack.peek().fields.get(ref.getIndex()).getValue().getName(); case CAST: return inferAlias(exprList, ((RexCall) expr).getOperands().get(0), -1); case AS: final RexCall call = (RexCall) expr; if (i >= 0) { exprList.set(i, call.getOperands().get(0)); } return ((NlsString) ((RexLiteral) call.getOperands().get(1)).getValue()) .getValue(); default: return null; } }
Example #10
Source File: RexBuilder.java From calcite with Apache License 2.0 | 5 votes |
private static Comparable zeroValue(RelDataType type) { switch (type.getSqlTypeName()) { case CHAR: return new NlsString(Spaces.of(type.getPrecision()), null, null); case VARCHAR: return new NlsString("", null, null); case BINARY: return new ByteString(new byte[type.getPrecision()]); case VARBINARY: return ByteString.EMPTY; case TINYINT: case SMALLINT: case INTEGER: case BIGINT: case DECIMAL: case FLOAT: case REAL: case DOUBLE: return BigDecimal.ZERO; case BOOLEAN: return false; case TIME: case DATE: case TIMESTAMP: return DateTimeUtils.ZERO_CALENDAR; case TIME_WITH_LOCAL_TIME_ZONE: return new TimeString(0, 0, 0); case TIMESTAMP_WITH_LOCAL_TIME_ZONE: return new TimestampString(0, 0, 0, 0, 0, 0); default: throw Util.unexpected(type.getSqlTypeName()); } }
Example #11
Source File: SqlDatePartOperator.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public boolean checkSingleOperandType(SqlCallBinding callBinding, SqlNode node, int iFormalOperand, boolean throwOnFailure) { // check that the input is a literal. if(!super.checkSingleOperandType(callBinding, node, iFormalOperand, throwOnFailure)) { return false; } final RelDataType type = callBinding.getValidator().deriveType(callBinding.getScope(), node); final SqlTypeName typeName = type.getSqlTypeName(); // Pass type checking for operators if it's of type 'ANY'. if (typeName.getFamily() == SqlTypeFamily.ANY) { return true; } if(!(typeName == SqlTypeName.CHAR || typeName == SqlTypeName.VARCHAR)) { if(throwOnFailure) { throw callBinding.newValidationSignatureError(); } return false; } final SqlLiteral literal = (SqlLiteral) node; final String value = ((NlsString)literal.getValue()).getValue(); if(validStrings.contains(value.toLowerCase())) { return true; } if(throwOnFailure) { throw callBinding.newValidationSignatureError(); //throw new SqlValidatorException(String.format("DATE_PART function only accepts the following values for a date type: %s.", Joiner.on(", ").join(validStrings)), null); } return false; }
Example #12
Source File: SqlLiteral.java From Bats with Apache License 2.0 | 5 votes |
/** * For calc program builder - value may be different than {@link #unparse} * Typical values: * * <ul> * <li>Hello, world!</li> * <li>12.34</li> * <li>{null}</li> * <li>1969-04-29</li> * </ul> * * @return string representation of the value */ public String toValue() { if (value == null) { return null; } switch (typeName) { case CHAR: // We want 'It''s superman!', not _ISO-8859-1'It''s superman!' return ((NlsString) value).getValue(); default: return value.toString(); } }
Example #13
Source File: SetOptionHandler.java From dremio-oss with Apache License 2.0 | 5 votes |
private static OptionValue createOptionValue(final String name, final OptionValue.OptionType type, final SqlLiteral literal) { final Object object = literal.getValue(); final SqlTypeName typeName = literal.getTypeName(); switch (typeName) { case DECIMAL: { final BigDecimal bigDecimal = (BigDecimal) object; if (bigDecimal.scale() == 0) { return OptionValue.createLong(type, name, bigDecimal.longValue()); } else { return OptionValue.createDouble(type, name, bigDecimal.doubleValue()); } } case DOUBLE: case FLOAT: return OptionValue.createDouble(type, name, ((BigDecimal) object).doubleValue()); case SMALLINT: case TINYINT: case BIGINT: case INTEGER: return OptionValue.createLong(type, name, ((BigDecimal) object).longValue()); case VARBINARY: case VARCHAR: case CHAR: return OptionValue.createString(type, name, ((NlsString) object).getValue()); case BOOLEAN: return OptionValue.createBoolean(type, name, (Boolean) object); default: throw UserException.validationError() .message("Dremio doesn't support assigning literals of type %s in SET statements.", typeName) .build(logger); } }
Example #14
Source File: SqlCharStringLiteral.java From Bats with Apache License 2.0 | 5 votes |
protected SqlAbstractStringLiteral concat1(List<SqlLiteral> literals) { return new SqlCharStringLiteral( NlsString.concat( Util.transform(literals, literal -> ((SqlCharStringLiteral) literal).getNlsString())), literals.get(0).getParserPosition()); }
Example #15
Source File: DataAdditionCmdHandler.java From dremio-oss with Apache License 2.0 | 5 votes |
/** * Helper method to create map of key, value pairs, the value is a Java type object. * @param args * @return */ @VisibleForTesting public void createStorageOptionsMap(final SqlNodeList args) { if (args == null || args.size() == 0) { return; } final ImmutableMap.Builder<String, Object> storageOptions = ImmutableMap.builder(); for (SqlNode operand : args) { if (operand.getKind() != SqlKind.ARGUMENT_ASSIGNMENT) { throw UserException.unsupportedError() .message("Unsupported argument type. Only assignment arguments (param => value) are supported.") .build(logger); } final List<SqlNode> operandList = ((SqlCall) operand).getOperandList(); final String name = ((SqlIdentifier) operandList.get(1)).getSimple(); SqlNode literal = operandList.get(0); if (!(literal instanceof SqlLiteral)) { throw UserException.unsupportedError() .message("Only literals are accepted for storage option values") .build(logger); } Object value = ((SqlLiteral)literal).getValue(); if (value instanceof NlsString) { value = ((NlsString)value).getValue(); } storageOptions.put(name, value); } this.storageOptionsMap = storageOptions.build(); }
Example #16
Source File: SqlLiteral.java From calcite with Apache License 2.0 | 5 votes |
/** * For calc program builder - value may be different than {@link #unparse} * Typical values: * * <ul> * <li>Hello, world!</li> * <li>12.34</li> * <li>{null}</li> * <li>1969-04-29</li> * </ul> * * @return string representation of the value */ public String toValue() { if (value == null) { return null; } switch (typeName) { case CHAR: // We want 'It''s superman!', not _ISO-8859-1'It''s superman!' return ((NlsString) value).getValue(); default: return value.toString(); } }
Example #17
Source File: RexBuilder.java From Bats with Apache License 2.0 | 5 votes |
private static Comparable zeroValue(RelDataType type) { switch (type.getSqlTypeName()) { case CHAR: return new NlsString(Spaces.of(type.getPrecision()), null, null); case VARCHAR: return new NlsString("", null, null); case BINARY: return new ByteString(new byte[type.getPrecision()]); case VARBINARY: return ByteString.EMPTY; case TINYINT: case SMALLINT: case INTEGER: case BIGINT: case DECIMAL: case FLOAT: case REAL: case DOUBLE: return BigDecimal.ZERO; case BOOLEAN: return false; case TIME: case DATE: case TIMESTAMP: return DateTimeUtils.ZERO_CALENDAR; case TIME_WITH_LOCAL_TIME_ZONE: return new TimeString(0, 0, 0); case TIMESTAMP_WITH_LOCAL_TIME_ZONE: return new TimestampString(0, 0, 0, 0, 0, 0); default: throw Util.unexpected(type.getSqlTypeName()); } }
Example #18
Source File: RexBuilder.java From Bats with Apache License 2.0 | 5 votes |
/** Returns an {@link NlsString} with spaces to make it at least a given * length. */ private static NlsString padRight(NlsString s, int length) { if (s.getValue().length() >= length) { return s; } return s.copy(padRight(s.getValue(), length)); }
Example #19
Source File: TypeConvertUtil.java From marble with Apache License 2.0 | 5 votes |
public static String toString(Object value) { if (value == null) { return null; } if (value instanceof NlsString) { return ((NlsString) value).getValue(); } else { return value.toString(); } }
Example #20
Source File: SplunkPushDownRule.java From calcite with Apache License 2.0 | 5 votes |
private String toString(boolean like, RexLiteral literal) { String value = null; SqlTypeName litSqlType = literal.getTypeName(); if (SqlTypeName.NUMERIC_TYPES.contains(litSqlType)) { value = literal.getValue().toString(); } else if (litSqlType == SqlTypeName.CHAR) { value = ((NlsString) literal.getValue()).getValue(); if (like) { value = value.replace("%", "*"); } value = searchEscape(value); } return value; }
Example #21
Source File: RexLiteral.java From calcite with Apache License 2.0 | 5 votes |
/** Returns whether a value is valid as a constant value, using the same * criteria as {@link #valueMatchesType}. */ public static boolean validConstant(Object o, Litmus litmus) { if (o == null || o instanceof BigDecimal || o instanceof NlsString || o instanceof ByteString || o instanceof Boolean) { return litmus.succeed(); } else if (o instanceof List) { List list = (List) o; for (Object o1 : list) { if (!validConstant(o1, litmus)) { return litmus.fail("not a constant: {}", o1); } } return litmus.succeed(); } else if (o instanceof Map) { @SuppressWarnings("unchecked") final Map<Object, Object> map = (Map) o; for (Map.Entry entry : map.entrySet()) { if (!validConstant(entry.getKey(), litmus)) { return litmus.fail("not a constant: {}", entry.getKey()); } if (!validConstant(entry.getValue(), litmus)) { return litmus.fail("not a constant: {}", entry.getValue()); } } return litmus.succeed(); } else { return litmus.fail("not a constant: {}", o); } }
Example #22
Source File: ShowSchemasHandler.java From Bats with Apache License 2.0 | 5 votes |
/** Rewrite the parse tree as SELECT ... FROM INFORMATION_SCHEMA.SCHEMATA ... */ @Override public SqlNode rewrite(SqlNode sqlNode) throws ForemanSetupException { SqlShowSchemas node = unwrap(sqlNode, SqlShowSchemas.class); List<SqlNode> selectList = Collections.singletonList(new SqlIdentifier(SCHS_COL_SCHEMA_NAME, SqlParserPos.ZERO)); SqlNode fromClause = new SqlIdentifier(Arrays.asList(IS_SCHEMA_NAME, InfoSchemaTableType.SCHEMATA.name()), SqlParserPos.ZERO); SqlNode where = null; SqlNode likePattern = node.getLikePattern(); if (likePattern != null) { SqlNode column = new SqlIdentifier(SCHS_COL_SCHEMA_NAME, SqlParserPos.ZERO); // schema names are case insensitive, wrap column in lower function, pattern to lower case if (likePattern instanceof SqlCharStringLiteral) { NlsString conditionString = ((SqlCharStringLiteral) likePattern).getNlsString(); likePattern = SqlCharStringLiteral.createCharString( conditionString.getValue().toLowerCase(), conditionString.getCharsetName(), likePattern.getParserPosition()); column = SqlStdOperatorTable.LOWER.createCall(SqlParserPos.ZERO, column); } where = DrillParserUtil.createCondition(column, SqlStdOperatorTable.LIKE, likePattern); } else if (node.getWhereClause() != null) { where = node.getWhereClause(); } return new SqlSelect(SqlParserPos.ZERO, null, new SqlNodeList(selectList, SqlParserPos.ZERO), fromClause, where, null, null, null, null, null, null); }
Example #23
Source File: SetOptionHandler.java From Bats with Apache License 2.0 | 5 votes |
private static Object sqlLiteralToObject(final SqlLiteral literal) { final Object object = literal.getValue(); final SqlTypeName typeName = literal.getTypeName(); switch (typeName) { case DECIMAL: { final BigDecimal bigDecimal = (BigDecimal) object; if (bigDecimal.scale() == 0) { return bigDecimal.longValue(); } else { return bigDecimal.doubleValue(); } } case DOUBLE: case FLOAT: return ((BigDecimal) object).doubleValue(); case SMALLINT: case TINYINT: case BIGINT: case INTEGER: return ((BigDecimal) object).longValue(); case VARBINARY: case VARCHAR: case CHAR: return ((NlsString) object).getValue().toString(); case BOOLEAN: return object; default: throw UserException.validationError() .message("Drill doesn't support assigning literals of type %s in SET statements.", typeName) .build(logger); } }
Example #24
Source File: AlterTableSetOptionHandler.java From dremio-oss with Apache License 2.0 | 5 votes |
private static AttributeValue createAttributeValue(final SqlLiteral literal) { final Object object = literal.getValue(); final SqlTypeName typeName = literal.getTypeName(); switch (typeName) { case DOUBLE: case FLOAT: return AttributeValue.of(((BigDecimal) object).doubleValue()); case SMALLINT: case TINYINT: case BIGINT: case INTEGER: return AttributeValue.of(((BigDecimal) object).longValue()); case VARBINARY: case VARCHAR: case CHAR: return AttributeValue.of(((NlsString) object).getValue()); case BOOLEAN: return AttributeValue.of((Boolean) object); default: throw UserException.validationError() .message("Dremio doesn't support assigning literals of type %s in SET statements.", typeName) .buildSilently(); } }
Example #25
Source File: RexImplicationCheckerTest.java From calcite with Apache License 2.0 | 4 votes |
public RexLiteral charLiteral(String z) { return rexBuilder.makeCharLiteral( new NlsString(z, null, SqlCollation.COERCIBLE)); }
Example #26
Source File: ORCSearchArgumentGenerator.java From dremio-oss with Apache License 2.0 | 4 votes |
@Override public Object visitLiteral(RexLiteral literal) { if (RexToExpr.isLiteralNull(literal)) { throw new IllegalArgumentException("this shouldn't be part of the input expression: " + literal); } /** * Refer {@link org.apache.hadoop.hive.ql.io.orc.RecordReaderImpl#getMin(ColumnStatistics)} * for literal type for given column type */ switch (literal.getType().getSqlTypeName()) { case VARCHAR: case CHAR: return Tuple.<Object, Type>of(((NlsString)literal.getValue()).getValue(), Type.STRING); case INTEGER: return Tuple.<Object, Type>of(getLong(literal), Type.LONG); case BIGINT: return Tuple.<Object, Type>of(getLong(literal), Type.LONG); case FLOAT: return Tuple.of(getDouble(literal), Type.FLOAT); case DOUBLE: return Tuple.of(getDouble(literal), Type.FLOAT); case DECIMAL: return Tuple.of(getDecimal(literal), Type.DECIMAL); case DATE: // In ORC filter evaluation values are read from file as long and converted to Date in similar way, // so the timezone shouldn't be a problem as the input to both here and in ORC reader // is millisSinceEpoch in UTC timezone. When this filter is converted to string (for testing purposes), // we could see different values depending upon the timezone of JVM return Tuple.of(new Date(literal.getValueAs(DateString.class).getMillisSinceEpoch()), Type.DATE); case TIMESTAMP: // In ORC filter evaluation values are read from file as long and converted to Timestamp in similar way, // so the timezone shouldn't be a problem as the input to both here and in ORC reader // is millisSinceEpoch in UTC timezone. When this filter is converted to string (for testing purposes), // we could see different values depending upon the timezone of JVM return Tuple.of(new Timestamp(literal.getValueAs(Long.class)), Type.TIMESTAMP); case BOOLEAN: return Tuple.of(RexLiteral.booleanValue(literal), Type.BOOLEAN); default: throw new IllegalArgumentException("this shouldn't be part of the input expression: " + literal); } }
Example #27
Source File: MetadataUtils.java From dremio-oss with Apache License 2.0 | 4 votes |
public static SearchQuery toSplitsSearchQuery(List<FilterProperties> filters, Field field) { Preconditions.checkNotNull(field); final CompleteType ct = CompleteType.fromField(field); final FieldType fieldType = getFieldType(ct); final String columnKey = PartitionChunkConverter.buildColumnKey(fieldType, field.getName()); final List<SearchQuery> filterQueries = Lists.newArrayList(); for (FilterProperties filter: filters) { final RexLiteral literal = filter.getLiteral(); SearchQuery matchingSplitsQuery = null; final RangeQueryInput rangeQueryInput; switch (ct.toMinorType()) { case BIGINT: rangeQueryInput = new RangeQueryInput( ((BigDecimal) literal.getValue()).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(), filter.getKind()); matchingSplitsQuery = SearchQueryUtils.newRangeLong(columnKey, (Long) rangeQueryInput.min, (Long) rangeQueryInput.max, rangeQueryInput.includeMin, rangeQueryInput.includeMax); break; case TIME: rangeQueryInput = new RangeQueryInput((int) ((GregorianCalendar) literal.getValue()).getTimeInMillis(), filter.getKind()); matchingSplitsQuery = SearchQueryUtils.newRangeInt(columnKey, (Integer) rangeQueryInput.min, (Integer) rangeQueryInput.max, rangeQueryInput.includeMin, rangeQueryInput.includeMax); break; case VARCHAR: if (literal.getValue() instanceof NlsString) { rangeQueryInput = new RangeQueryInput(((NlsString) literal.getValue()).getValue(), filter.getKind()); } else { rangeQueryInput = new RangeQueryInput((literal.getValue3().toString()), filter.getKind()); } matchingSplitsQuery = SearchQueryUtils.newRangeTerm(columnKey, (String) rangeQueryInput.min, (String) rangeQueryInput.max, rangeQueryInput.includeMin, rangeQueryInput.includeMax); break; case FLOAT4: rangeQueryInput = new RangeQueryInput(((BigDecimal) literal.getValue()).floatValue(), filter.getKind()); matchingSplitsQuery = SearchQueryUtils.newRangeFloat(columnKey, (Float) rangeQueryInput.min, (Float) rangeQueryInput.max, rangeQueryInput.includeMin, rangeQueryInput.includeMax); break; case FLOAT8: rangeQueryInput = new RangeQueryInput(((BigDecimal) literal.getValue()).doubleValue(), filter.getKind()); matchingSplitsQuery = SearchQueryUtils.newRangeDouble(columnKey, (Double) rangeQueryInput.min, (Double) rangeQueryInput.max, rangeQueryInput.includeMin, rangeQueryInput.includeMax); break; case INT: rangeQueryInput = new RangeQueryInput(((BigDecimal) literal.getValue()).setScale(0, BigDecimal.ROUND_HALF_UP).intValue(), filter.getKind()); matchingSplitsQuery = SearchQueryUtils.newRangeInt(columnKey, (Integer) rangeQueryInput.min, (Integer) rangeQueryInput.max, rangeQueryInput.includeMin, rangeQueryInput.includeMax); break; case DATE: case TIMESTAMP: rangeQueryInput = new RangeQueryInput(((GregorianCalendar) literal.getValue()).getTimeInMillis(), filter.getKind()); matchingSplitsQuery = SearchQueryUtils.newRangeLong(columnKey, (Long) rangeQueryInput.min, (Long) rangeQueryInput.max, rangeQueryInput.includeMin, rangeQueryInput.includeMax); break; default: throw new UnsupportedOperationException("type not supported " + ct.toMinorType()); } if (matchingSplitsQuery != null) { filterQueries.add(matchingSplitsQuery); } } return SearchQueryUtils.and(filterQueries); }
Example #28
Source File: SqlRefreshReflection.java From dremio-oss with Apache License 2.0 | 4 votes |
public String getMaterializationId() { return ((NlsString) materializationId.getValue()).getValue(); }
Example #29
Source File: DremioRelToSqlConverter.java From dremio-oss with Apache License 2.0 | 4 votes |
private SqlCharStringLiteralWithCollation(NlsString val, SqlParserPos pos, SqlCollation collation) { super(val, pos); this.collation = collation; }
Example #30
Source File: SqlCreateFunction.java From streamline with Apache License 2.0 | 4 votes |
public String jarName() { return jarName == null ? null : ((NlsString)SqlLiteral.value(jarName)).getValue(); }