本文整理汇总了Java中org.apache.calcite.rel.type.RelDataType.getSqlTypeName方法的典型用法代码示例。如果您正苦于以下问题:Java RelDataType.getSqlTypeName方法的具体用法?Java RelDataType.getSqlTypeName怎么用?Java RelDataType.getSqlTypeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rel.type.RelDataType
的用法示例。
在下文中一共展示了RelDataType.getSqlTypeName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createColumnFormatConversion
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
/**
* Apply any data format conversion expressions.
*/
private RexNode createColumnFormatConversion(final DrillScanRel hiveScanRel, final DrillScanRel nativeScanRel,
final String colName, final RexBuilder rb) {
final RelDataType outputType = hiveScanRel.getRowType().getField(colName, false, false).getType();
final RelDataTypeField inputField = nativeScanRel.getRowType().getField(colName, false, false);
final RexInputRef inputRef = rb.makeInputRef(inputField.getType(), inputField.getIndex());
if (outputType.getSqlTypeName() == SqlTypeName.TIMESTAMP) {
// TIMESTAMP is stored as INT96 by Hive in ParquetFormat. Use convert_fromTIMESTAMP_IMPALA UDF to convert
// INT96 format data to TIMESTAMP
return rb.makeCall(INT96_TO_TIMESTAMP, inputRef);
}
return inputRef;
}
示例2: deriveSumType
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
@Override
public RelDataType deriveSumType(
RelDataTypeFactory typeFactory, RelDataType argumentType) {
SqlTypeName sqlTypeName = argumentType.getSqlTypeName();
switch (sqlTypeName) {
case TINYINT:
case SMALLINT:
case INTEGER:
case BIGINT:
return typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), argumentType.isNullable());
case FLOAT:
case DOUBLE:
return typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.DOUBLE), argumentType.isNullable());
}
return argumentType;
}
示例3: FieldType
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
public FieldType(String name, RelDataType dataType) {
this.name = name;
this.type = dataType.getSqlTypeName();
Integer p = null;
Integer s = null;
Integer fractionalSecondPrecision = null;
switch (dataType.getSqlTypeName()) {
case CHAR:
case BINARY:
case VARBINARY:
case VARCHAR:
p = dataType.getPrecision();
break;
case DECIMAL:
p = dataType.getPrecision();
s = dataType.getScale();
break;
case INTERVAL_YEAR_MONTH:
case INTERVAL_DAY_TIME:
p = dataType.getIntervalQualifier().getStartPrecisionPreservingDefault();
default:
break;
}
this.precision = p;
this.scale = s;
this.intervalQualifier = dataType.getIntervalQualifier();
this.isNullable = dataType.isNullable();
}
示例4: checkSingleOperandType
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
@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;
}
示例5: isTemporal
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
private boolean isTemporal(RelDataType rt){
switch(rt.getSqlTypeName()){
case DATE:
case TIME:
case TIMESTAMP:
return true;
default:
return false;
}
}
示例6: areRowTypesCompatible
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
public static boolean areRowTypesCompatible(
RelDataType rowType1,
RelDataType rowType2,
boolean compareNames,
boolean allowSubstring) {
if (rowType1 == rowType2) {
return true;
}
if (compareNames) {
// if types are not identity-equal, then either the names or
// the types must be different
return false;
}
if (rowType2.getFieldCount() != rowType1.getFieldCount()) {
return false;
}
final List<RelDataTypeField> f1 = rowType1.getFieldList();
final List<RelDataTypeField> f2 = rowType2.getFieldList();
for (Pair<RelDataTypeField, RelDataTypeField> pair : Pair.zip(f1, f2)) {
final RelDataType type1 = pair.left.getType();
final RelDataType type2 = pair.right.getType();
// If one of the types is ANY comparison should succeed
if (type1.getSqlTypeName() == SqlTypeName.ANY
|| type2.getSqlTypeName() == SqlTypeName.ANY) {
continue;
}
if (type1.getSqlTypeName() != type2.getSqlTypeName()) {
if (allowSubstring
&& (type1.getSqlTypeName() == SqlTypeName.CHAR && type2.getSqlTypeName() == SqlTypeName.CHAR)
&& (type1.getPrecision() <= type2.getPrecision())) {
return true;
}
// Check if Drill implicit casting can resolve the incompatibility
List<TypeProtos.MinorType> types = Lists.newArrayListWithCapacity(2);
types.add(Types.getMinorTypeFromName(type1.getSqlTypeName().getName()));
types.add(Types.getMinorTypeFromName(type2.getSqlTypeName().getName()));
if(TypeCastRules.getLeastRestrictiveType(types) != null) {
return true;
}
return false;
}
}
return true;
}
示例7: FieldType
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
public FieldType(String name, RelDataType dataType) {
this.name = name;
this.type = dataType.getSqlTypeName();
Integer p = null;
Integer s = null;
switch (dataType.getSqlTypeName()) {
case CHAR:
case BINARY:
case VARBINARY:
case VARCHAR:
p = dataType.getPrecision();
break;
case DECIMAL:
p = dataType.getPrecision();
s = dataType.getScale();
break;
case TIME:
case TIMESTAMP:
p = dataType.getPrecision();
break;
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:
p = dataType.getIntervalQualifier().getStartPrecisionPreservingDefault();
default:
break;
}
this.precision = p;
this.scale = s;
this.intervalQualifier = dataType.getIntervalQualifier();
this.isNullable = dataType.isNullable();
}
示例8: getMinorTypeFromCalciteType
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
/**
* Given a Calcite's RelDataType, return a Dremio's corresponding TypeProtos.MinorType
*/
public static TypeProtos.MinorType getMinorTypeFromCalciteType(final RelDataType relDataType) {
final SqlTypeName sqlTypeName = relDataType.getSqlTypeName();
return getMinorTypeFromCalciteType(sqlTypeName);
}
示例9: inferReturnType
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
@Override
public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
final RelDataTypeFactory factory = opBinding.getTypeFactory();
if (functions.isEmpty()) {
return factory.createTypeWithNullability(
factory.createSqlType(SqlTypeName.ANY),
true);
}
// The following logic is just a safe play:
// Even if any of the input arguments has ANY type,
// it "might" still be possible to determine the return type based on other non-ANY types
for (RelDataType type : opBinding.collectOperandTypes()) {
if (getMinorTypeFromCalciteType(type) == TypeProtos.MinorType.LATE) {
// This code for boolean output type is added for addressing DRILL-1729
// In summary, if we have a boolean output function in the WHERE-CLAUSE,
// this logic can validate and execute user queries seamlessly
boolean allBooleanOutput = true;
for (BaseFunctionHolder function : functions) {
if (!function.isReturnTypeIndependent() || function.getReturnType(null).toMinorType() != TypeProtos.MinorType.BIT) {
allBooleanOutput = false;
break;
}
}
if(allBooleanOutput) {
return factory.createTypeWithNullability(
factory.createSqlType(SqlTypeName.BOOLEAN), true);
} else {
return factory.createTypeWithNullability(
factory.createSqlType(SqlTypeName.ANY),
true);
}
}
}
final BaseFunctionHolder func = resolveFunctionHolder(opBinding, functions);
final RelDataType returnType = getReturnType(opBinding, func);
return returnType.getSqlTypeName() == SqlTypeName.VARBINARY
? createCalciteTypeWithNullability(factory, SqlTypeName.ANY, returnType.isNullable())
: returnType;
}
示例10: areRowTypesCompatible
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
public static boolean areRowTypesCompatible(
RelDataType rowType1,
RelDataType rowType2,
boolean compareNames,
boolean allowSubstring) {
if (rowType1 == rowType2) {
return true;
}
if (compareNames) {
// if types are not identity-equal, then either the names or
// the types must be different
return false;
}
if (rowType2.getFieldCount() != rowType1.getFieldCount()) {
return false;
}
final List<RelDataTypeField> f1 = rowType1.getFieldList();
final List<RelDataTypeField> f2 = rowType2.getFieldList();
for (Pair<RelDataTypeField, RelDataTypeField> pair : Pair.zip(f1, f2)) {
final RelDataType type1 = pair.left.getType();
final RelDataType type2 = pair.right.getType();
// If one of the types is ANY comparison should succeed
if (type1.getSqlTypeName() == SqlTypeName.ANY
|| type2.getSqlTypeName() == SqlTypeName.ANY) {
continue;
}
if (type1.getSqlTypeName() != type2.getSqlTypeName()) {
if (allowSubstring
&& (type1.getSqlTypeName() == SqlTypeName.CHAR && type2.getSqlTypeName() == SqlTypeName.CHAR)
&& (type1.getPrecision() <= type2.getPrecision())) {
return true;
}
// Check if Dremio implicit casting can resolve the incompatibility
List<TypeProtos.MinorType> types = Lists.newArrayListWithCapacity(2);
types.add(Types.getMinorTypeFromName(type1.getSqlTypeName().getName()));
types.add(Types.getMinorTypeFromName(type2.getSqlTypeName().getName()));
if(TypeCastRules.getLeastRestrictiveType(types) != null) {
return true;
}
return false;
}
}
return true;
}