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


Java RelDataTypeFactory.createSqlIntervalType方法代码示例

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


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

示例1: 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

示例2: 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

示例3: getRowType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType getRowType(RelDataTypeFactory factory) {

    // if there are no fields defined, this is a dynamic view.
    if (isDynamic()) {
      return new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory);
    }

    List<RelDataType> types = Lists.newArrayList();
    List<String> names = Lists.newArrayList();

    for (FieldType field : fields) {
      names.add(field.getName());
      RelDataType type;
      if (   SqlTypeFamily.INTERVAL_YEAR_MONTH == field.getType().getFamily()
          || SqlTypeFamily.INTERVAL_DAY_TIME   == field.getType().getFamily() ) {
       type = factory.createSqlIntervalType( field.getIntervalQualifier() );
      } else if (field.getPrecision() == null && field.getScale() == null) {
        type = factory.createSqlType(field.getType());
      } else if (field.getPrecision() != null && field.getScale() == null) {
        type = factory.createSqlType(field.getType(), field.getPrecision());
      } else {
        type = factory.createSqlType(field.getType(), field.getPrecision(), field.getScale());
      }

      if (field.getIsNullable()) {
        types.add(factory.createTypeWithNullability(type, true));
      } else {
        types.add(type);
      }
    }
    return factory.createStructType(types, names);
  }
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:33,代码来源:View.java

示例4: getRowType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType getRowType(RelDataTypeFactory factory) {

    List<RelDataType> types = Lists.newArrayList();
    List<String> names = Lists.newArrayList();

    for (FieldType field : fields) {
      names.add(field.getName());
      RelDataType type;
      if (   SqlTypeFamily.INTERVAL_YEAR_MONTH == field.getType().getFamily()
          || SqlTypeFamily.INTERVAL_DAY_TIME   == field.getType().getFamily() ) {
       type = factory.createSqlIntervalType( field.getIntervalQualifier() );
      } else if (field.getType().equals(SqlTypeName.ARRAY) || field.getType().equals(SqlTypeName.MAP)) {
        type = factory.createSqlType(SqlTypeName.ANY);
      } else if (field.getPrecision() == null && field.getScale() == null) {
        type = factory.createSqlType(field.getType());
      } else if (field.getPrecision() != null && field.getScale() == null) {
        type = factory.createSqlType(field.getType(), field.getPrecision());
      } else {
        type = factory.createSqlType(field.getType(), field.getPrecision(), field.getScale());
      }

      if (field.getIsNullable()) {
        types.add(factory.createTypeWithNullability(type, true));
      } else {
        types.add(type);
      }
    }
    return factory.createStructType(types, names);
  }
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:30,代码来源:View.java

示例5: 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;
  switch (sqlTypeName) {
    case INTERVAL_YEAR:
    case INTERVAL_YEAR_MONTH:
    case INTERVAL_MONTH:
      type = typeFactory.createSqlIntervalType(
        new SqlIntervalQualifier(
          TimeUnit.YEAR,
          TimeUnit.MONTH,
          SqlParserPos.ZERO));
      break;
    case INTERVAL_DAY:
    case INTERVAL_DAY_HOUR:
    case INTERVAL_DAY_MINUTE:
    case INTERVAL_DAY_SECOND:
    case INTERVAL_HOUR:
    case INTERVAL_HOUR_MINUTE:
    case INTERVAL_HOUR_SECOND:
    case INTERVAL_MINUTE:
    case INTERVAL_MINUTE_SECOND:
    case INTERVAL_SECOND:
      type = typeFactory.createSqlIntervalType(
        new SqlIntervalQualifier(
          TimeUnit.DAY,
          TimeUnit.MINUTE,
          SqlParserPos.ZERO));
      break;
    case VARCHAR:
      type = typeFactory.createSqlType(sqlTypeName, TypeHelper.VARCHAR_DEFAULT_CAST_LEN);
    default:
      type = typeFactory.createSqlType(sqlTypeName);
  }
  return typeFactory.createTypeWithNullability(type, isNullable);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:46,代码来源:TypeInferenceUtils.java

示例6: createSqlType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType createSqlType(RelDataTypeFactory typeFactory) {
  BitString bitString;
  switch (typeName) {
  case NULL:
  case BOOLEAN:
    RelDataType ret = typeFactory.createSqlType(typeName);
    ret = typeFactory.createTypeWithNullability(ret, null == value);
    return ret;
  case BINARY:
    bitString = (BitString) value;
    int bitCount = bitString.getBitCount();
    return typeFactory.createSqlType(SqlTypeName.BINARY, bitCount / 8);
  case CHAR:
    NlsString string = (NlsString) value;
    Charset charset = string.getCharset();
    if (null == charset) {
      charset = typeFactory.getDefaultCharset();
    }
    SqlCollation collation = string.getCollation();
    if (null == collation) {
      collation = SqlCollation.COERCIBLE;
    }
    RelDataType type =
        typeFactory.createSqlType(
            SqlTypeName.CHAR,
            string.getValue().length());
    type =
        typeFactory.createTypeWithCharsetAndCollation(
            type,
            charset,
            collation);
    return type;

  case INTERVAL_YEAR:
  case INTERVAL_YEAR_MONTH:
  case INTERVAL_MONTH:
  case INTERVAL_DAY:
  case INTERVAL_DAY_HOUR:
  case INTERVAL_DAY_MINUTE:
  case INTERVAL_DAY_SECOND:
  case INTERVAL_HOUR:
  case INTERVAL_HOUR_MINUTE:
  case INTERVAL_HOUR_SECOND:
  case INTERVAL_MINUTE:
  case INTERVAL_MINUTE_SECOND:
  case INTERVAL_SECOND:
    SqlIntervalLiteral.IntervalValue intervalValue =
        (SqlIntervalLiteral.IntervalValue) value;
    return typeFactory.createSqlIntervalType(
        intervalValue.getIntervalQualifier());

  case SYMBOL:
    return typeFactory.createSqlType(SqlTypeName.SYMBOL);

  case INTEGER: // handled in derived class
  case TIME: // handled in derived class
  case VARCHAR: // should never happen
  case VARBINARY: // should never happen

  default:
    throw Util.needToImplement(toString() + ", operand=" + value);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:64,代码来源:SqlLiteral.java


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