本文整理汇总了Java中org.apache.calcite.sql.type.SqlTypeName.CHAR属性的典型用法代码示例。如果您正苦于以下问题:Java SqlTypeName.CHAR属性的具体用法?Java SqlTypeName.CHAR怎么用?Java SqlTypeName.CHAR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.calcite.sql.type.SqlTypeName
的用法示例。
在下文中一共展示了SqlTypeName.CHAR属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitCall
@Override
public Boolean visitCall(RexCall call) {
if (call.getOperator() == SqlStdOperatorTable.ITEM) {
final RexNode op0 = call.getOperands().get(0);
final RexNode op1 = call.getOperands().get(1);
if (op0 instanceof RexInputRef &&
op1 instanceof RexLiteral && ((RexLiteral) op1).getTypeName() == SqlTypeName.CHAR) {
return true;
} else if (op0 instanceof RexCall &&
op1 instanceof RexLiteral && ((RexLiteral) op1).getTypeName() == SqlTypeName.CHAR) {
return op0.accept(this);
}
}
return false;
}
示例2: checkSingleOperandType
@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;
}
示例3: 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;
}
示例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 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;
}