当前位置: 首页>>代码示例>>Java>>正文


Java SqlTypeName.CHAR属性代码示例

本文整理汇总了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;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:17,代码来源:DrillProjectRelBase.java

示例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;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:37,代码来源:SqlDatePartOperator.java

示例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;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:46,代码来源:DrillRelOptUtil.java

示例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;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:46,代码来源:MoreRelOptUtil.java


注:本文中的org.apache.calcite.sql.type.SqlTypeName.CHAR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。