• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SqlDataTypeSpec类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.calcite.sql.SqlDataTypeSpec的典型用法代码示例。如果您正苦于以下问题:Java SqlDataTypeSpec类的具体用法?Java SqlDataTypeSpec怎么用?Java SqlDataTypeSpec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: expandAvg

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
private SqlNode expandAvg(
    final SqlNode arg, final RelDataType avgType, final SqlRexContext cx) {
  final SqlParserPos pos = SqlParserPos.ZERO;
  final SqlNode sum =
      SqlStdOperatorTable.SUM.createCall(pos, arg);
  final RexNode sumRex = cx.convertExpression(sum);
  final SqlNode sumCast;
  if (!sumRex.getType().equals(avgType)) {
    sumCast = SqlStdOperatorTable.CAST.createCall(pos,
        new SqlDataTypeSpec(
            new SqlIdentifier(avgType.getSqlTypeName().getName(), pos),
            avgType.getPrecision(), avgType.getScale(), null, null, pos));
  } else {
    sumCast = sum;
  }
  final SqlNode count =
      SqlStdOperatorTable.COUNT.createCall(pos, arg);
  return SqlStdOperatorTable.DIVIDE.createCall(
      pos, sumCast, count);
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:StandardConvertletTable.java


示例2: getExtendedColumns

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
/**
 * Gets a list of extended columns with field indices to the underlying table.
 */
public static List<RelDataTypeField> getExtendedColumns(
    RelDataTypeFactory typeFactory, SqlValidatorTable table, SqlNodeList extendedColumns) {
  final ImmutableList.Builder<RelDataTypeField> extendedFields =
      ImmutableList.builder();
  final ExtensibleTable extTable = table.unwrap(ExtensibleTable.class);
  int extendedFieldOffset =
      extTable == null
          ? table.getRowType().getFieldCount()
          : extTable.getExtendedColumnOffset();
  for (final Pair<SqlIdentifier, SqlDataTypeSpec> pair : pairs(extendedColumns)) {
    final SqlIdentifier identifier = pair.left;
    final SqlDataTypeSpec type = pair.right;
    extendedFields.add(
        new RelDataTypeFieldImpl(identifier.toString(),
            extendedFieldOffset++,
            type.deriveType(typeFactory)));
  }
  return extendedFields.build();
}
 
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:SqlValidatorUtil.java


示例3: registerTypeAppendOp

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
/**
 * Creates and registers a convertlet for an operator in which
 * the SQL representation needs the result type appended
 * as an extra argument (e.g. CAST).
 *
 * @param op operator instance
 */
private void registerTypeAppendOp(final SqlOperator op) {
  registerOp(
      op,
      new RexSqlConvertlet() {
        public SqlNode convertCall(
            RexToSqlNodeConverter converter,
            RexCall call) {
          SqlNode[] operands =
              convertExpressionList(converter, call.operands);
          if (operands == null) {
            return null;
          }
          List<SqlNode> operandList =
              new ArrayList<SqlNode>(Arrays.asList(operands));
          SqlDataTypeSpec typeSpec =
              SqlTypeUtil.convertTypeToSpec(call.getType());
          operandList.add(typeSpec);
          return new SqlBasicCall(
              op,
              operandList.toArray(new SqlNode[operandList.size()]),
              SqlParserPos.ZERO);
        }
      });
}
 
开发者ID:apache,项目名称:calcite,代码行数:32,代码来源:RexSqlStandardConvertletTable.java


示例4: execute

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
public void execute(CalcitePrepare.Context context) {
  final List<String> path = context.getDefaultSchemaPath();
  CalciteSchema schema = context.getRootSchema();
  for (String p : path) {
    schema = schema.getSubSchema(p, true);
  }
  final JavaTypeFactory typeFactory = new JavaTypeFactoryImpl();
  final RelDataTypeFactory.Builder builder = typeFactory.builder();
  for (Pair<SqlIdentifier, SqlDataTypeSpec> pair : nameTypes()) {
    builder.add(pair.left.getSimple(),
        pair.right.deriveType(typeFactory, true));
  }
  final RelDataType rowType = builder.build();
  schema.add(name.getSimple(),
      new MutableArrayTable(name.getSimple(),
          RelDataTypeImpl.proto(rowType)));
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:SqlCreateTable.java


示例5: visit

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
@Override
public SqlNode visit(SqlDataTypeSpec type) {
  for(String strType : disabledType) {
    if(type.getTypeName().getSimple().equalsIgnoreCase(strType)) {
      unsupportedOperatorCollector.setException(SqlUnsupportedException.ExceptionType.DATA_TYPE,
          type.getTypeName().getSimple() + " is not supported\n" +
          "See Apache Drill JIRA: DRILL-1959");
      throw new UnsupportedOperationException();
    }
  }

  return type;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:14,代码来源:UnsupportedOperatorsVisitor.java


示例6: visit

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
@Override
public SqlNode visit(SqlDataTypeSpec type) {
  for(String strType : disabledType) {
    if(type.getTypeName().getSimple().equalsIgnoreCase(strType)) {
      // see DRILL-1959
      unsupportedOperatorCollector.setException(SqlUnsupportedException.ExceptionType.DATA_TYPE,
          type.getTypeName().getSimple() + " is not supported");
      throw new UnsupportedOperationException();
    }
  }

  return type;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:14,代码来源:UnsupportedOperatorsVisitor.java


示例7: toSql

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
private SqlNode toSql(RelDataType type) {
    switch (dialect.getDatabaseProduct()) {
    case MYSQL:
        switch (type.getSqlTypeName()) {
        case VARCHAR:
            // MySQL doesn't have a VARCHAR type, only CHAR.
            return new SqlDataTypeSpec(new SqlIdentifier("CHAR", POS),
                    type.getPrecision(), -1, null, null, POS);
        case INTEGER:
            return new SqlDataTypeSpec(new SqlIdentifier("_UNSIGNED", POS),
                    type.getPrecision(), -1, null, null, POS);
        default:
        }
        break;
    default:
    }
    if (type instanceof BasicSqlType) {
        return new SqlDataTypeSpec(
                new SqlIdentifier(type.getSqlTypeName().name(), POS),
                type.getPrecision(),
                type.getScale(),
                type.getCharset() != null
                        && dialect.supportsCharSet()
                        ? type.getCharset().name()
                        : null,
                null,
                POS);
    }
    throw new AssertionError(type); // TODO: implement
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:31,代码来源:JdbcImplementor.java


示例8: field

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
public TableBuilderInfo field(String name, SqlDataTypeSpec type, ColumnConstraint constraint) {
  RelDataType dataType = type.deriveType(typeFactory);
  if (constraint instanceof ColumnConstraint.PrimaryKey) {
    ColumnConstraint.PrimaryKey pk = (ColumnConstraint.PrimaryKey) constraint;
    Preconditions.checkState(primaryKey == -1, "There are more than one primary key in the table");
    primaryKey = fields.size();
    primaryKeyMonotonicity = pk.monotonicity();
  }
  fields.add(new FieldType(name, dataType));
  return this;
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:12,代码来源:CompilerUtil.java


示例9: toSql

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
private SqlNode toSql(RelDataType type) {
  switch (dialect.getDatabaseProduct()) {
    case MYSQL:
      switch (type.getSqlTypeName()) {
        case VARCHAR:
          // MySQL doesn't have a VARCHAR type, only CHAR.
          return new SqlDataTypeSpec(new SqlIdentifier("CHAR", POS),
              type.getPrecision(), -1, null, null, POS);
        case INTEGER:
          return new SqlDataTypeSpec(new SqlIdentifier("_UNSIGNED", POS),
              type.getPrecision(), -1, null, null, POS);
      }
      break;
  }
  if (type instanceof BasicSqlType) {
    return new SqlDataTypeSpec(
        new SqlIdentifier(type.getSqlTypeName().name(), POS),
        type.getPrecision(),
        type.getScale(),
        type.getCharset() != null
            && dialect.supportsCharSet()
            ? type.getCharset().name()
            : null,
        null,
        POS);
  }

  return SqlTypeUtil.convertTypeToSpec(type);
  //throw new AssertionError(type); // TODO: implement
}
 
开发者ID:qubole,项目名称:quark,代码行数:31,代码来源:RelToSqlConverter.java


示例10: SqlColumnDeclaration

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
/** Creates a SqlColumnDeclaration; use {@link SqlDdlNodes#column}. */
SqlColumnDeclaration(SqlParserPos pos, SqlIdentifier name,
    SqlDataTypeSpec dataType, SqlNode expression,
    ColumnStrategy strategy) {
  super(pos);
  this.name = name;
  this.dataType = dataType;
  this.expression = expression;
  this.strategy = strategy;
}
 
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:SqlColumnDeclaration.java


示例11: visit

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
public RelDataType visit(SqlDataTypeSpec dataType) {
  // Q. How can a data type have a type?
  // A. When it appears in an expression. (Say as the 2nd arg to the
  //    CAST operator.)
  validateDataType(dataType);
  return dataType.deriveType(SqlValidatorImpl.this);
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:SqlValidatorImpl.java


示例12: getMonotonicity

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
public SqlMonotonicity getMonotonicity(SqlNode expr) {
  return
      ((expr instanceof SqlLiteral)
          || (expr instanceof SqlDynamicParam)
          || (expr instanceof SqlDataTypeSpec)) ? SqlMonotonicity.CONSTANT
          : SqlMonotonicity.NOT_MONOTONIC;
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:EmptyScope.java


示例13: pairs

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
/** Converts a list of extended columns
 * (of the form [name0, type0, name1, type1, ...])
 * into a list of (name, type) pairs. */
private static List<Pair<SqlIdentifier, SqlDataTypeSpec>> pairs(
    SqlNodeList extendedColumns) {
  final List list = extendedColumns.getList();
  //noinspection unchecked
  return Pair.zip(Util.quotientList(list, 2, 0),
      Util.quotientList(list, 2, 1));
}
 
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:SqlValidatorUtil.java


示例14: getCastSpec

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
@Override public SqlNode getCastSpec(RelDataType type) {
  switch (type.getSqlTypeName()) {
  case VARCHAR:
    // MySQL doesn't have a VARCHAR type, only CHAR.
    return new SqlDataTypeSpec(new SqlIdentifier("CHAR", SqlParserPos.ZERO),
        type.getPrecision(), -1, null, null, SqlParserPos.ZERO);
  case INTEGER:
    return new SqlDataTypeSpec(new SqlIdentifier("_UNSIGNED", SqlParserPos.ZERO),
        type.getPrecision(), -1, null, null, SqlParserPos.ZERO);
  }
  return super.getCastSpec(type);
}
 
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:MysqlSqlDialect.java


示例15: unparse

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
@Override public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {
  writer.keyword("CREATE");
  writer.keyword("TABLE");
  name.unparse(writer, leftPrec, rightPrec);
  SqlWriter.Frame frame = writer.startList("(", ")");
  for (Pair<SqlIdentifier, SqlDataTypeSpec> pair : nameTypes()) {
    writer.sep(",");
    pair.left.unparse(writer, leftPrec, rightPrec); // name
    pair.right.unparse(writer, leftPrec, rightPrec); // type
    if (Boolean.FALSE.equals(pair.right.getNullable())) {
      writer.keyword("NOT NULL");
    }
  }
  writer.endList(frame);
}
 
开发者ID:apache,项目名称:calcite,代码行数:16,代码来源:SqlCreateTable.java


示例16: nameTypes

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
/** Creates a list of (name, type) pairs from {@link #columnList}, in which
 * they alternate. */
private List<Pair<SqlIdentifier, SqlDataTypeSpec>> nameTypes() {
  final List list = columnList.getList();
  //noinspection unchecked
  return Pair.zip((List<SqlIdentifier>) Util.quotientList(list, 2, 0),
      Util.quotientList((List<SqlDataTypeSpec>) list, 2, 1));
}
 
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:SqlCreateTable.java


示例17: literal

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
private SqlNode literal(RelDataType type, Object value) {
  if (value == null) {
    int precision = type.getPrecision();
    int scale = type.getScale();
    if (!type.getSqlTypeName().allowsPrec()) {
      precision = -1;
    }
    if (!type.getSqlTypeName().allowsScale()) {
      scale = -1;
    }
    return SqlStdOperatorTable.CAST.createCall(
        SqlParserPos.ZERO,
        SqlLiteral.createNull(SqlParserPos.ZERO),
        new SqlDataTypeSpec(
            new SqlIdentifier(type.getSqlTypeName().getName(),
                SqlParserPos.ZERO), precision, scale, null, null,
            SqlParserPos.ZERO));
  }
  switch (type.getSqlTypeName()) {
  case BOOLEAN:
    return SqlLiteral.createBoolean((Boolean) value, SqlParserPos.ZERO);
  case TINYINT:
  case SMALLINT:
  case INTEGER:
  case BIGINT:
    return SqlLiteral.createExactNumeric(
        value.toString(), SqlParserPos.ZERO);
  case CHAR:
  case VARCHAR:
    return SqlLiteral.createCharString(value.toString(), SqlParserPos.ZERO);
  case TIMESTAMP:
    TimestampString ts = TimestampString.fromMillisSinceEpoch((Long) value);
    return SqlLiteral.createTimestamp(ts, type.getPrecision(),
        SqlParserPos.ZERO);
  default:
    throw new AssertionError(type);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:39,代码来源:SqlOperatorBaseTest.java


示例18: visit

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
@Override public Void visit(SqlDataTypeSpec type) {
  return format(type);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:4,代码来源:SqlNodes.java


示例19: visit

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
@Override
public T visit(SqlDataTypeSpec spec) {
  throw new UnsupportedOperationException("SqlDataTypeSpec " + spec);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:BaseSqlVisitor.java


示例20: visit

import org.apache.calcite.sql.SqlDataTypeSpec; //导入依赖的package包/类
@Override
public List<SqlIdentifier> visit(SqlDataTypeSpec type) {
  return Collections.emptyList();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:AncestorsVisitor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CorruptFileBlockIterator类代码示例发布时间:2022-05-22
下一篇:
Java Connector类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap