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


Java SqlTypeName.BIGINT属性代码示例

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


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

示例1: getSqlTypeNameForTimeUnit

/**
 * For Extract and date_part functions, infer the return types based on timeUnit
 */
public static SqlTypeName getSqlTypeNameForTimeUnit(String timeUnit) {
  switch (timeUnit.toUpperCase()){
    case "YEAR":
    case "MONTH":
    case "DAY":
    case "HOUR":
    case "MINUTE":
    case "SECOND":
    case "CENTURY":
    case "DECADE":
    case "DOW":
    case "DOY":
    case "MILLENNIUM":
    case "QUARTER":
    case "WEEK":
    case "EPOCH":
      return SqlTypeName.BIGINT;
    default:
      throw UserException
          .functionError()
          .message("extract function supports the following time units: YEAR, MONTH, DAY, HOUR, MINUTE, SECOND")
          .build(logger);
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:27,代码来源:TypeInferenceUtils.java

示例2: updateScan

public RelNode updateScan(IncrementallyUpdateable scan) {
  if (UPDATE_COLUMN.equals(refreshColumn)) {
    return scan;
  }

  RelDataTypeField refreshField = scan.getRowType().getField(refreshColumn, false, false);

  if(refreshField == null){
    throw UserException.dataReadError()
      .message("Table does not include column identified for incremental update of name '%s'.", refreshField.getName())
      .build(logger);
  } else if(refreshField.getType().getSqlTypeName() != SqlTypeName.BIGINT){
    throw UserException.dataReadError()
      .message("Dremio only supports incremental column update on BIGINT types. The identified column was of type %s.", refreshField.getType().getSqlTypeName())
      .build(logger);
  }

  final RelBuilder relBuilder = newCalciteRelBuilderWithoutContext(scan.getCluster());

  relBuilder.push(scan);

  List<String> newFieldNames = ImmutableList.<String>builder().addAll(scan.getRowType().getFieldNames()).add(UPDATE_COLUMN).build();

  Iterable<RexInputRef> projects = FluentIterable.from(scan.getRowType().getFieldNames())
    .transform(new Function<String, RexInputRef>() {
      @Override
      public RexInputRef apply(String fieldName) {
        return relBuilder.field(fieldName);
      }
    })
    .append(relBuilder.field(refreshColumn));

  relBuilder.project(projects, newFieldNames);

  return relBuilder.build();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:36,代码来源:IncrementalUpdateUtils.java

示例3: inferReturnType

@Override
public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
  final RelDataTypeFactory factory = opBinding.getTypeFactory();
  SqlTypeName typeToCastTo = null;
  if (opBinding instanceof SqlCallBinding) {
    SqlCallBinding sqlCallBinding = (SqlCallBinding) opBinding;
    if (sqlCallBinding.operand(1).getKind() == SqlKind.LITERAL) {
      String type = null;
      try {
        SqlLiteral sqlLiteral = (SqlLiteral) sqlCallBinding.operand(1);
        type = ((NlsString) sqlLiteral.getValue()).getValue();
        switch(type) {
          case "JSON":
            typeToCastTo = SqlTypeName.ANY;
            break;
          case "UTF8":
          case "UTF16":
            typeToCastTo = SqlTypeName.VARCHAR;
            break;
          case "BOOLEAN_BYTE":
            typeToCastTo = SqlTypeName.BOOLEAN;
            break;
          case "TINYINT_BE":
          case "TINYINT":
            typeToCastTo = SqlTypeName.TINYINT;
            break;
          case "SMALLINT_BE":
          case "SMALLINT":
            typeToCastTo = SqlTypeName.SMALLINT;
            break;
          case "INT_BE":
          case "INT":
          case "INT_HADOOPV":
            typeToCastTo = SqlTypeName.INTEGER;
            break;
          case "BIGINT_BE":
          case "BIGINT":
          case "BIGINT_HADOOPV":
            typeToCastTo = SqlTypeName.BIGINT;
            break;
          case "FLOAT":
            typeToCastTo = SqlTypeName.FLOAT;
            break;
          case "DOUBLE":
            typeToCastTo = SqlTypeName.DOUBLE;
            break;
          case "DATE_EPOCH_BE":
          case "DATE_EPOCH":
            typeToCastTo = SqlTypeName.DATE;
            break;
          case "TIME_EPOCH_BE":
          case "TIME_EPOCH":
            typeToCastTo = SqlTypeName.TIME;
            break;
          case "TIMESTAMP_EPOCH":
          case "TIMESTAMP_IMPALA":
            typeToCastTo = SqlTypeName.TIMESTAMP;
            break;
          default:
            typeToCastTo = SqlTypeName.ANY;
            break;
        }
      } catch (final ClassCastException e) {
        logger.debug("Failed to parse string for convert_from()");
      }
    }
  }

  if (typeToCastTo == null) {
    typeToCastTo = SqlTypeName.ANY;
  }
  return factory.createTypeWithNullability(
      factory.createSqlType(typeToCastTo),
      true);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:75,代码来源:TypeInferenceUtils.java


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