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


Java RelDataTypeFactory.createTypeWithNullability方法代码示例

本文整理汇总了Java中org.apache.calcite.rel.type.RelDataTypeFactory.createTypeWithNullability方法的典型用法代码示例。如果您正苦于以下问题:Java RelDataTypeFactory.createTypeWithNullability方法的具体用法?Java RelDataTypeFactory.createTypeWithNullability怎么用?Java RelDataTypeFactory.createTypeWithNullability使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.calcite.rel.type.RelDataTypeFactory的用法示例。


在下文中一共展示了RelDataTypeFactory.createTypeWithNullability方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getField

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataTypeField getField(RelDataTypeFactory typeFactory, String fieldName) {

    /* First check if this field name exists in our field list */
    for (RelDataTypeField f : fields) {
      if (fieldName.equalsIgnoreCase(f.getName())) {
        return f;
      }
    }

    /* This field does not exist in our field list add it */
    RelDataTypeField newField = new RelDataTypeFieldImpl(fieldName, fields.size(), typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.ANY), true));

    /* Add the name to our list of field names */
    fields.add(newField);

    return newField;
  }
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:18,代码来源:RelDataTypeHolder.java

示例2: createCalciteTypeWithNullability

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
private RelDataType createCalciteTypeWithNullability(RelDataTypeFactory typeFactory,
                                                     SqlTypeName sqlTypeName,
                                                     boolean isNullable) {
  RelDataType type;
  if (sqlTypeName == SqlTypeName.INTERVAL_DAY_TIME) {
    type = typeFactory.createSqlIntervalType(
        new SqlIntervalQualifier(
            TimeUnit.DAY,
            TimeUnit.MINUTE,
            SqlParserPos.ZERO));
  } else if (sqlTypeName == SqlTypeName.INTERVAL_YEAR_MONTH) {
    type = typeFactory.createSqlIntervalType(
        new SqlIntervalQualifier(
            TimeUnit.YEAR,
            TimeUnit.MONTH,
           SqlParserPos.ZERO));
  } else if (sqlTypeName == SqlTypeName.VARCHAR) {
    type = typeFactory.createSqlType(sqlTypeName, TypeHelper.VARCHAR_DEFAULT_CAST_LEN);
  } else {
    type = typeFactory.createSqlType(sqlTypeName);
  }
  return typeFactory.createTypeWithNullability(type, isNullable);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:24,代码来源:DrillConstExecutor.java

示例3: convertCall

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
@Override
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
  final RexBuilder rexBuilder = cx.getRexBuilder();
  final List<SqlNode> operands = call.getOperandList();
  final List<RexNode> exprs = new LinkedList<>();

  RelDataTypeFactory typeFactory = cx.getTypeFactory();

  //RelDataType nullableReturnType =

  for (SqlNode node: operands) {
     exprs.add(cx.convertExpression(node));
  }

  // Determine NULL-able using 2nd argument's Null-able.
  RelDataType returnType = typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), exprs.get(1).getType().isNullable());

  return rexBuilder.makeCall(returnType, call.getOperator(), exprs);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:20,代码来源:DrillExtractConvertlet.java

示例4: convertCall

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
@Override
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
  final RexBuilder rexBuilder = cx.getRexBuilder();
  final List<SqlNode> operands = call.getOperandList();
  final List<RexNode> exprs = new LinkedList<>();

  String timeUnit = ((SqlIntervalQualifier) operands.get(0)).timeUnitRange.toString();

  RelDataTypeFactory typeFactory = cx.getTypeFactory();

  //RelDataType nullableReturnType =

  for (SqlNode node: operands) {
     exprs.add(cx.convertExpression(node));
  }

  final RelDataType returnType
      = typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), exprs.get(1).getType().isNullable());
  return rexBuilder.makeCall(returnType, call.getOperator(), exprs);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:21,代码来源:ExtractConvertlet.java

示例5: convertCall

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
@Override
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
  final RexBuilder rexBuilder = cx.getRexBuilder();

  final SqlLiteral literal = (SqlLiteral) call.getOperandList().get(0);
  final String value = ((NlsString)literal.getValue()).getValue();
  TimeUnitRange range = VALID_PERIODS.get(value.toLowerCase());
  Preconditions.checkNotNull(range, "Unhandle range type: %s.", value);
  List<RexNode> exprs = new ArrayList<>();

  exprs.add(rexBuilder.makeFlag(range));
  exprs.add(cx.convertExpression(call.getOperandList().get(1)));

  RelDataTypeFactory typeFactory = cx.getTypeFactory();
  final RelDataType returnType
      = typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), exprs.get(1).getType().isNullable());
  return rexBuilder.makeCall(returnType, SqlStdOperatorTable.EXTRACT, exprs);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:19,代码来源:SqlDatePartOperator.java

示例6: getReturnType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
private static RelDataType getReturnType(final SqlOperatorBinding opBinding, final BaseFunctionHolder func) {
  final RelDataTypeFactory factory = opBinding.getTypeFactory();

  // least restrictive type (nullable ANY type)
  final RelDataType nullableAnyType = factory.createTypeWithNullability(
          factory.createSqlType(SqlTypeName.ANY),
          true);

  if(!func.isReturnTypeIndependent()){
    return nullableAnyType;
  }

  CompleteType returnType = func.getReturnType(null);
  if(returnType.isList() || returnType.isComplex() || returnType.isUnion()  || returnType.isLate()){
    return nullableAnyType;
  }

  final TypeProtos.MinorType minorType = returnType.toMinorType();
  final SqlTypeName sqlTypeName = getCalciteTypeFromMinorType(minorType);
  if (sqlTypeName == null) {
    return nullableAnyType;
  }

  return createCalciteTypeWithNullability(factory, sqlTypeName, true);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:26,代码来源:TypeInferenceUtils.java

示例7: inferReturnType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
@Override
public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
  final RelDataTypeFactory factory = opBinding.getTypeFactory();

  boolean isNullable = true;
  int precision = 0;
  for(RelDataType relDataType : opBinding.collectOperandTypes()) {
    if(!relDataType.isNullable()) {
      isNullable = false;
    }

    // If the underlying columns cannot offer information regarding the precision (i.e., the length) of the VarChar,
    // Dremio uses the largest to represent it
    if(relDataType.getPrecision() == TypeHelper.VARCHAR_DEFAULT_CAST_LEN
        || relDataType.getPrecision() == RelDataType.PRECISION_NOT_SPECIFIED) {
      precision = TypeHelper.VARCHAR_DEFAULT_CAST_LEN;
    } else {
      precision += relDataType.getPrecision();
    }
  }

  return factory.createTypeWithNullability(
      factory.createSqlType(SqlTypeName.VARCHAR, precision),
      isNullable);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:26,代码来源:TypeInferenceUtils.java

示例8: inferReturnType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
    final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
    final TimeUnit unit = (TimeUnit) opBinding.getOperandLiteralValue(0);
    switch (unit) {
        case HOUR:
        case MINUTE:
        case SECOND:
        case MILLISECOND:
        case MICROSECOND:
            return typeFactory.createTypeWithNullability(
                    typeFactory.createSqlType(SqlTypeName.TIMESTAMP),
                    opBinding.getOperandType(1).isNullable()
                    || opBinding.getOperandType(2).isNullable());
        default:
            return opBinding.getOperandType(2);
    }
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:SqlTimestampAddFunction.java

示例9: inferReturnType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
@Override public RelDataType
inferReturnType(SqlOperatorBinding opBinding) {
	final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
	final RelDataType leftType = opBinding.getOperandType(0);
	final IntervalSqlType unitType =
		(IntervalSqlType) opBinding.getOperandType(1);
	switch (unitType.getIntervalQualifier().getStartUnit()) {
		case HOUR:
		case MINUTE:
		case SECOND:
		case MILLISECOND:
		case MICROSECOND:
			return typeFactory.createTypeWithNullability(
				typeFactory.createSqlType(SqlTypeName.TIMESTAMP),
				leftType.isNullable() || unitType.isNullable());
		default:
			return leftType;
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:20,代码来源:SqlStdOperatorTable.java

示例10: createCalciteTypeWithNullability

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/**
 * Given a {@link SqlTypeName} and nullability, create a RelDataType from the RelDataTypeFactory
 *
 * @param typeFactory RelDataTypeFactory used to create the RelDataType
 * @param sqlTypeName the given SqlTypeName
 * @param isNullable  the nullability of the created RelDataType
 * @return RelDataType Type of call
 */
public static RelDataType createCalciteTypeWithNullability(RelDataTypeFactory typeFactory,
                                                           SqlTypeName sqlTypeName,
                                                           boolean isNullable) {
  RelDataType type;
  if (sqlTypeName == SqlTypeName.INTERVAL_DAY_TIME) {
    type = typeFactory.createSqlIntervalType(
        new SqlIntervalQualifier(
            TimeUnit.DAY,
            TimeUnit.MINUTE,
            SqlParserPos.ZERO));
  } else if (sqlTypeName == SqlTypeName.INTERVAL_YEAR_MONTH) {
    type = typeFactory.createSqlIntervalType(
        new SqlIntervalQualifier(
            TimeUnit.YEAR,
            TimeUnit.MONTH,
            SqlParserPos.ZERO));
  } else if (sqlTypeName == SqlTypeName.VARCHAR) {
    type = typeFactory.createSqlType(sqlTypeName, Types.MAX_VARCHAR_LENGTH);
  } else {
    type = typeFactory.createSqlType(sqlTypeName);
  }
  return typeFactory.createTypeWithNullability(type, isNullable);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:32,代码来源:TypeInferenceUtils.java

示例11: deriveSumType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
@Override
public RelDataType deriveSumType(RelDataTypeFactory typeFactory, RelDataType argumentType) {
    if (argumentType instanceof BasicSqlType) {
        switch (argumentType.getSqlTypeName()) {
        case INTEGER:
        case SMALLINT:
        case TINYINT:
            return typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT),
                    argumentType.isNullable());
        case DECIMAL:
            return typeFactory.createTypeWithNullability(
                    typeFactory.createSqlType(SqlTypeName.DECIMAL, 19, argumentType.getScale()),
                    argumentType.isNullable());
        default:
            break;
        }
    }
    return argumentType;
}
 
开发者ID:apache,项目名称:kylin,代码行数:20,代码来源:KylinRelDataTypeSystem.java

示例12: makeNullableIfOperandsAre

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/**
 * Recreates a given RelDataType with nullability iff any of the operands
 * of a call are nullable.
 */
public static RelDataType makeNullableIfOperandsAre(
        final SqlValidator validator,
        final SqlValidatorScope scope,
        final SqlCall call,
        RelDataType type) {
    for (SqlNode operand : call.getOperandList()) {
        RelDataType operandType = validator.deriveType(scope, operand);

        if (containsNullable(operandType)) {
            RelDataTypeFactory typeFactory = validator.getTypeFactory();
            type = typeFactory.createTypeWithNullability(type, true);
            break;
        }
    }
    return type;
}
 
开发者ID:apache,项目名称:kylin,代码行数:21,代码来源:SqlTypeUtil.java

示例13: getReturnType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType getReturnType(RelDataTypeFactory typeFactory,
    SqlOperatorBinding opBinding) {
  // Strict and semi-strict functions can return null even if their Java
  // functions return a primitive type. Because when one of their arguments
  // is null, they won't even be called.
  final RelDataType returnType = getReturnType(typeFactory);
  switch (getNullPolicy(method)) {
  case STRICT:
    for (RelDataType type : opBinding.collectOperandTypes()) {
      if (type.isNullable()) {
        return typeFactory.createTypeWithNullability(returnType, true);
      }
    }
    break;
  case SEMI_STRICT:
    return typeFactory.createTypeWithNullability(returnType, true);
  }
  return returnType;
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:ScalarFunctionImpl.java

示例14: toSql

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/** Converts a type in Java format to a SQL-oriented type. */
public static RelDataType toSql(final RelDataTypeFactory typeFactory,
    RelDataType type) {
  if (type instanceof RelRecordType) {
    return typeFactory.createStructType(
        Lists.transform(type.getFieldList(),
            new Function<RelDataTypeField, RelDataType>() {
              public RelDataType apply(RelDataTypeField a0) {
                return toSql(typeFactory, a0.getType());
              }
            }),
        type.getFieldNames());
  }
  if (type instanceof JavaType) {
    return typeFactory.createTypeWithNullability(
        typeFactory.createSqlType(type.getSqlTypeName()),
        type.isNullable());
  }
  return type;
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:JavaTypeFactoryImpl.java

示例15: makeNullableIfOperandsAre

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/**
 * Recreates a given RelDataType with nullability iff any of the operands
 * of a call are nullable.
 */
public static RelDataType makeNullableIfOperandsAre(
    final SqlValidator validator,
    final SqlValidatorScope scope,
    final SqlCall call,
    RelDataType type) {
  for (SqlNode operand : call.getOperandList()) {
    RelDataType operandType = validator.deriveType(scope, operand);

    if (containsNullable(operandType)) {
      RelDataTypeFactory typeFactory = validator.getTypeFactory();
      type = typeFactory.createTypeWithNullability(type, true);
      break;
    }
  }
  return type;
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:SqlTypeUtil.java


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