本文整理汇总了Java中org.apache.calcite.sql.type.SqlTypeName.ANY属性的典型用法代码示例。如果您正苦于以下问题:Java SqlTypeName.ANY属性的具体用法?Java SqlTypeName.ANY怎么用?Java SqlTypeName.ANY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.calcite.sql.type.SqlTypeName
的用法示例。
在下文中一共展示了SqlTypeName.ANY属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCalciteTypeFromMinorType
/**
* Given a Dremio's TypeProtos.MinorType, return a Calcite's corresponding SqlTypeName
*/
public static SqlTypeName getCalciteTypeFromMinorType(final TypeProtos.MinorType type) {
if(!CalciteTypeMaps.MINOR_TO_CALCITE_TYPE_MAPPING.containsKey(type)) {
return SqlTypeName.ANY;
}
return CalciteTypeMaps.MINOR_TO_CALCITE_TYPE_MAPPING.get(type);
}
示例2: getSqlTypeName
@Override
public SqlTypeName getSqlTypeName() {
return SqlTypeName.ANY;
}
示例3: getSqlTypeName
@Override
public SqlTypeName getSqlTypeName() {
return SqlTypeName.ANY;
}
示例4: areRowTypesCompatible
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;
}
示例5: inferReturnType
@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);
}
示例6: areRowTypesCompatible
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;
}