Java Code Examples for org.apache.calcite.sql.type.SqlTypeName#FLOAT
The following examples show how to use
org.apache.calcite.sql.type.SqlTypeName#FLOAT .
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: JethroDataSqlDialect.java From Bats with Apache License 2.0 | 6 votes |
private SqlTypeName parse(String strType) { switch (strType.toLowerCase(Locale.ROOT)) { case "bigint": case "long": return SqlTypeName.BIGINT; case "integer": case "int": return SqlTypeName.INTEGER; case "double": return SqlTypeName.DOUBLE; case "float": return SqlTypeName.FLOAT; case "string": return SqlTypeName.VARCHAR; case "timestamp": return SqlTypeName.TIMESTAMP; default: return SqlTypeName.ANY; } }
Example 2
Source File: JethroDataSqlDialect.java From calcite with Apache License 2.0 | 6 votes |
private SqlTypeName parse(String strType) { switch (strType.toLowerCase(Locale.ROOT)) { case "bigint": case "long": return SqlTypeName.BIGINT; case "integer": case "int": return SqlTypeName.INTEGER; case "double": return SqlTypeName.DOUBLE; case "float": return SqlTypeName.FLOAT; case "string": return SqlTypeName.VARCHAR; case "timestamp": return SqlTypeName.TIMESTAMP; default: return SqlTypeName.ANY; } }
Example 3
Source File: DremioArgChecker.java From dremio-oss with Apache License 2.0 | 5 votes |
public static Checker ofFloat(String argName) { return new Checker() { @Override public boolean check(RelDataType type) { return type.getSqlTypeName() == SqlTypeName.FLOAT; } @Override public String signature() { return argName + " <FLOAT>"; } }; }
Example 4
Source File: JoinTranslator.java From samza with Apache License 2.0 | 5 votes |
private void validateJoinKeyType(RexInputRef ref) { SqlTypeName sqlTypeName = ref.getType().getSqlTypeName(); // Primitive types and ANY (for the record key) are supported in the key if (sqlTypeName != SqlTypeName.BOOLEAN && sqlTypeName != SqlTypeName.TINYINT && sqlTypeName != SqlTypeName.SMALLINT && sqlTypeName != SqlTypeName.INTEGER && sqlTypeName != SqlTypeName.CHAR && sqlTypeName != SqlTypeName.BIGINT && sqlTypeName != SqlTypeName.VARCHAR && sqlTypeName != SqlTypeName.DOUBLE && sqlTypeName != SqlTypeName.FLOAT && sqlTypeName != SqlTypeName.ANY && sqlTypeName != SqlTypeName.OTHER) { log.error("Unsupported key type " + sqlTypeName + " used in join condition."); throw new SamzaException("Unsupported key type used in join condition."); } }
Example 5
Source File: SamzaSqlValidator.java From samza with Apache License 2.0 | 5 votes |
private boolean compareFieldTypes(RelDataType outputFieldType, SqlFieldSchema sqlFieldSchema, RelDataType selectQueryFieldType, RelSchemaProvider outputRelSchemaProvider) { SqlTypeName outputSqlType = outputFieldType.getSqlTypeName(); SqlTypeName projectSqlType = selectQueryFieldType.getSqlTypeName(); if (projectSqlType == SqlTypeName.ANY || outputSqlType == SqlTypeName.ANY) { return true; } else if (outputSqlType != SqlTypeName.ROW && outputSqlType == projectSqlType) { return true; } switch (outputSqlType) { case CHAR: return projectSqlType == SqlTypeName.VARCHAR; case VARCHAR: return projectSqlType == SqlTypeName.CHAR; case BIGINT: return projectSqlType == SqlTypeName.INTEGER; case INTEGER: return projectSqlType == SqlTypeName.BIGINT; case FLOAT: return projectSqlType == SqlTypeName.DOUBLE; case DOUBLE: return projectSqlType == SqlTypeName.FLOAT; case ROW: try { validateOutputRecords(sqlFieldSchema.getRowSchema(), (RelRecordType) outputFieldType, (RelRecordType) selectQueryFieldType, outputRelSchemaProvider); } catch (SamzaSqlValidatorException e) { LOG.error("A field in select query does not match with the output schema.", e); return false; } return true; default: return false; } }
Example 6
Source File: Checker.java From samza with Apache License 2.0 | 5 votes |
/** * Converts the {@link SamzaSqlFieldType} to the calcite {@link SqlTypeName}. * @param samzaSqlFieldType the samza sql field type. * @return the converted calcite SqlTypeName. */ @VisibleForTesting static SqlTypeName toCalciteSqlType(SamzaSqlFieldType samzaSqlFieldType) { switch (samzaSqlFieldType) { case ANY: case ROW: return SqlTypeName.ANY; case MAP: return SqlTypeName.MAP; case ARRAY: return SqlTypeName.ARRAY; case REAL: return SqlTypeName.REAL; case DOUBLE: return SqlTypeName.DOUBLE; case STRING: return SqlTypeName.VARCHAR; case INT16: case INT32: return SqlTypeName.INTEGER; case FLOAT: return SqlTypeName.FLOAT; case INT64: return SqlTypeName.BIGINT; case BOOLEAN: return SqlTypeName.BOOLEAN; case BYTES: return SqlTypeName.VARBINARY; default: String msg = String.format("Field Type %s is not supported", samzaSqlFieldType); LOG.error(msg); throw new SamzaException(msg); } }
Example 7
Source File: TypeInferenceUtils.java From dremio-oss with Apache License 2.0 | 4 votes |
@Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) { final RelDataTypeFactory factory = opBinding.getTypeFactory(); SqlTypeName typeToCastTo = null; if (opBinding instanceof SqlCallBinding) { SqlCallBinding sqlCallBinding = (SqlCallBinding) opBinding; if (sqlCallBinding.operand(1).getKind() == SqlKind.LITERAL) { String type = null; try { SqlLiteral sqlLiteral = (SqlLiteral) sqlCallBinding.operand(1); type = ((NlsString) sqlLiteral.getValue()).getValue(); switch(type) { case "JSON": typeToCastTo = SqlTypeName.ANY; break; case "UTF8": case "UTF16": typeToCastTo = SqlTypeName.VARCHAR; break; case "BOOLEAN_BYTE": typeToCastTo = SqlTypeName.BOOLEAN; break; case "TINYINT_BE": case "TINYINT": typeToCastTo = SqlTypeName.TINYINT; break; case "SMALLINT_BE": case "SMALLINT": typeToCastTo = SqlTypeName.SMALLINT; break; case "INT_BE": case "INT": case "INT_HADOOPV": typeToCastTo = SqlTypeName.INTEGER; break; case "BIGINT_BE": case "BIGINT": case "BIGINT_HADOOPV": typeToCastTo = SqlTypeName.BIGINT; break; case "FLOAT": typeToCastTo = SqlTypeName.FLOAT; break; case "DOUBLE": typeToCastTo = SqlTypeName.DOUBLE; break; case "DATE_EPOCH_BE": case "DATE_EPOCH": typeToCastTo = SqlTypeName.DATE; break; case "TIME_EPOCH_BE": case "TIME_EPOCH": typeToCastTo = SqlTypeName.TIME; break; case "TIMESTAMP_EPOCH": case "TIMESTAMP_IMPALA": typeToCastTo = SqlTypeName.TIMESTAMP; break; default: typeToCastTo = SqlTypeName.ANY; break; } } catch (final ClassCastException e) { logger.debug("Failed to parse string for convert_from()"); } } } if (typeToCastTo == null) { typeToCastTo = SqlTypeName.ANY; } return factory.createTypeWithNullability( factory.createSqlType(typeToCastTo), true); }