org.apache.calcite.rex.RexBuilder.matchNullability()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(72)

本文整理了Java中org.apache.calcite.rex.RexBuilder.matchNullability方法的一些代码示例,展示了RexBuilder.matchNullability的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RexBuilder.matchNullability方法的具体详情如下:
包路径:org.apache.calcite.rex.RexBuilder
类名称:RexBuilder
方法名:matchNullability

RexBuilder.matchNullability介绍

[英]Ensures that a type's nullability matches a value's nullability.
[中]确保类型的可空性与值的可空性匹配。

代码示例

代码示例来源:origin: Qihoo360/Quicksql

/**
 * Ensures expression is interpreted as a specified type. The returned
 * expression may be wrapped with a cast.
 *
 * @param type             desired type
 * @param node             expression
 * @param matchNullability whether to correct nullability of specified
 *                         type to match the expression; this usually should
 *                         be true, except for explicit casts which can
 *                         override default nullability
 * @return a casted expression or the original expression
 */
public RexNode ensureType(
  RelDataType type,
  RexNode node,
  boolean matchNullability) {
 RelDataType targetType = type;
 if (matchNullability) {
  targetType = matchNullability(type, node);
 }
 if (targetType.getSqlTypeName() == SqlTypeName.ANY
   && (!matchNullability
     || targetType.isNullable() == node.getType().isNullable())) {
  return node;
 }
 if (!node.getType().equals(targetType)) {
  return makeCast(targetType, node);
 }
 return node;
}

代码示例来源:origin: org.apache.calcite/calcite-core

/**
 * Ensures expression is interpreted as a specified type. The returned
 * expression may be wrapped with a cast.
 *
 * @param type             desired type
 * @param node             expression
 * @param matchNullability whether to correct nullability of specified
 *                         type to match the expression; this usually should
 *                         be true, except for explicit casts which can
 *                         override default nullability
 * @return a casted expression or the original expression
 */
public RexNode ensureType(
  RelDataType type,
  RexNode node,
  boolean matchNullability) {
 RelDataType targetType = type;
 if (matchNullability) {
  targetType = matchNullability(type, node);
 }
 if (targetType.getSqlTypeName() == SqlTypeName.ANY
   && (!matchNullability
     || targetType.isNullable() == node.getType().isNullable())) {
  return node;
 }
 if (!node.getType().equals(targetType)) {
  return makeCast(targetType, node);
 }
 return node;
}

代码示例来源:origin: Qihoo360/Quicksql

/**
 * Retrieves an interval or decimal node's integer representation
 *
 * @param node the interval or decimal value as an opaque type
 * @return an integer representation of the decimal value
 */
public RexNode decodeIntervalOrDecimal(RexNode node) {
 assert SqlTypeUtil.isDecimal(node.getType())
   || SqlTypeUtil.isInterval(node.getType());
 RelDataType bigintType = typeFactory.createSqlType(SqlTypeName.BIGINT);
 return makeReinterpretCast(
   matchNullability(bigintType, node), node, makeLiteral(false));
}

代码示例来源:origin: org.apache.calcite/calcite-core

/**
 * Retrieves an interval or decimal node's integer representation
 *
 * @param node the interval or decimal value as an opaque type
 * @return an integer representation of the decimal value
 */
public RexNode decodeIntervalOrDecimal(RexNode node) {
 assert SqlTypeUtil.isDecimal(node.getType())
   || SqlTypeUtil.isInterval(node.getType());
 RelDataType bigintType = typeFactory.createSqlType(SqlTypeName.BIGINT);
 return makeReinterpretCast(
   matchNullability(bigintType, node), node, makeLiteral(false));
}

相关文章

微信公众号

最新文章

更多