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


Java SqlParserPos.ZERO属性代码示例

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


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

示例1: rewrite

/** Rewrite the parse tree as SELECT ... FROM INFORMATION_SCHEMA.SCHEMATA ... */
@Override
public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException, ForemanSetupException {
  SqlShowSchemas node = unwrap(sqlNode, SqlShowSchemas.class);
  List<SqlNode> selectList =
      ImmutableList.of((SqlNode) new SqlIdentifier(SCHS_COL_SCHEMA_NAME, SqlParserPos.ZERO));

  SqlNode fromClause = new SqlIdentifier(
      ImmutableList.of(IS_SCHEMA_NAME, TAB_SCHEMATA), null, SqlParserPos.ZERO, null);

  SqlNode where = null;
  final SqlNode likePattern = node.getLikePattern();
  if (likePattern != null) {
    where = DrillParserUtil.createCondition(new SqlIdentifier(SCHS_COL_SCHEMA_NAME, SqlParserPos.ZERO),
                                            SqlStdOperatorTable.LIKE, likePattern);
  } else if (node.getWhereClause() != null) {
    where = node.getWhereClause();
  }

  return new SqlSelect(SqlParserPos.ZERO, null, new SqlNodeList(selectList, SqlParserPos.ZERO),
      fromClause, where, null, null, null, null, null, null);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:22,代码来源:ShowSchemasHandler.java

示例2: FieldType

@JsonCreator
public FieldType(
    @JsonProperty("name")                       String name,
    @JsonProperty("type")                       SqlTypeName type,
    @JsonProperty("precision")                  Integer precision,
    @JsonProperty("scale")                      Integer scale,
    @JsonProperty("startUnit")                  TimeUnit startUnit,
    @JsonProperty("endUnit")                    TimeUnit endUnit,
    @JsonProperty("fractionalSecondPrecision")  Integer fractionalSecondPrecision,
    @JsonProperty("isNullable")                 Boolean isNullable) {
  this.name = name;
  this.type = type;
  this.precision = precision;
  this.scale = scale;
  this.intervalQualifier =
      null == startUnit
      ? null
      : new SqlIntervalQualifier(
          startUnit, precision, endUnit, fractionalSecondPrecision, SqlParserPos.ZERO );

  // Property "isNullable" is not part of the initial view definition and
  // was added in DRILL-2342.  If the default value is null, consider it as
  // "true".  It is safe to default to "nullable" than "required" type.
  this.isNullable = isNullable == null ? true : isNullable;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:25,代码来源:View.java

示例3: expandAvg

private SqlNode expandAvg(
    final SqlNode arg) {
  final SqlParserPos pos = SqlParserPos.ZERO;
  final SqlNode sum =
      SqlStdOperatorTable.SUM.createCall(pos, arg);
  final SqlNode count =
      SqlStdOperatorTable.COUNT.createCall(pos, arg);
  final SqlNode sumAsDouble =
      CastHighOp.createCall(pos, sum);
  return SqlStdOperatorTable.DIVIDE.createCall(
      pos, sumAsDouble, count);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:12,代码来源:DrillAvgVarianceConvertlet.java

示例4: SqlAggOperator

public SqlAggOperator(String name, int argCountMin, int argCountMax, SqlReturnTypeInference sqlReturnTypeInference) {
  super(name,
      new SqlIdentifier(name, SqlParserPos.ZERO),
      SqlKind.OTHER_FUNCTION,
      sqlReturnTypeInference,
      null,
      Checker.getChecker(argCountMin, argCountMax),
      SqlFunctionCategory.USER_DEFINED_FUNCTION);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:9,代码来源:SqlAggOperator.java

示例5: SqlOperatorImpl

public SqlOperatorImpl(String name, int argCountMin, int argCountMax, boolean isDeterministic,
    SqlReturnTypeInference sqlReturnTypeInference, SqlSyntax syntax) {
  super(new SqlIdentifier(name, SqlParserPos.ZERO),
      sqlReturnTypeInference,
      null,
      Checker.getChecker(argCountMin, argCountMax),
      null,
      SqlFunctionCategory.USER_DEFINED_FUNCTION);
  this.isDeterministic = isDeterministic;
  this.syntax = syntax;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:11,代码来源:SqlOperatorImpl.java

示例6: DrillSqlOperator

public DrillSqlOperator(String name, int argCount, MajorType returnType, boolean isDeterminisitic) {
  super(new SqlIdentifier(name, SqlParserPos.ZERO), DynamicReturnType.INSTANCE, null, new Checker(argCount), null, SqlFunctionCategory.USER_DEFINED_FUNCTION);
  this.returnType = Preconditions.checkNotNull(returnType);
  this.isDeterministic = isDeterminisitic;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:5,代码来源:DrillSqlOperator.java

示例7: expandVariance

private SqlNode expandVariance(
    final SqlNode arg,
    boolean biased,
    boolean sqrt) {
  /* stddev_pop(x) ==>
   *   power(
   *    (sum(x * x) - sum(x) * sum(x) / count(x))
   *    / count(x),
   *    .5)

   * stddev_samp(x) ==>
   *  power(
   *    (sum(x * x) - sum(x) * sum(x) / count(x))
   *    / (count(x) - 1),
   *    .5)

   * var_pop(x) ==>
   *    (sum(x * x) - sum(x) * sum(x) / count(x))
   *    / count(x)

   * var_samp(x) ==>
   *    (sum(x * x) - sum(x) * sum(x) / count(x))
   *    / (count(x) - 1)
   */
  final SqlParserPos pos = SqlParserPos.ZERO;
  final SqlNode argSquared =
      SqlStdOperatorTable.MULTIPLY.createCall(pos, arg, arg);
  final SqlNode sumArgSquared =
      SqlStdOperatorTable.SUM.createCall(pos, argSquared);
  final SqlNode sum =
      SqlStdOperatorTable.SUM.createCall(pos, arg);
  final SqlNode sumSquared =
      SqlStdOperatorTable.MULTIPLY.createCall(pos, sum, sum);
  final SqlNode count =
      SqlStdOperatorTable.COUNT.createCall(pos, arg);
  final SqlNode avgSumSquared =
      SqlStdOperatorTable.DIVIDE.createCall(
          pos, sumSquared, count);
  final SqlNode diff =
      SqlStdOperatorTable.MINUS.createCall(
          pos, sumArgSquared, avgSumSquared);
  final SqlNode denominator;
  if (biased) {
    denominator = count;
  } else {
    final SqlNumericLiteral one =
        SqlLiteral.createExactNumeric("1", pos);
    denominator =
        SqlStdOperatorTable.MINUS.createCall(
            pos, count, one);
  }
  final SqlNode diffAsDouble =
      CastHighOp.createCall(pos, diff);
  final SqlNode div =
      SqlStdOperatorTable.DIVIDE.createCall(
          pos, diffAsDouble, denominator);
  SqlNode result = div;
  if (sqrt) {
    final SqlNumericLiteral half =
        SqlLiteral.createExactNumeric("0.5", pos);
    result =
        SqlStdOperatorTable.POWER.createCall(pos, div, half);
  }
  return result;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:65,代码来源:DrillAvgVarianceConvertlet.java

示例8: DrillSqlAggOperator

public DrillSqlAggOperator(String name, int argCount) {
  super(name, new SqlIdentifier(name, SqlParserPos.ZERO), SqlKind.OTHER_FUNCTION, DynamicReturnType.INSTANCE, null, new Checker(argCount), SqlFunctionCategory.USER_DEFINED_FUNCTION);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:3,代码来源:DrillSqlAggOperator.java

示例9: rewrite

/** Rewrite the parse tree as SELECT ... FROM INFORMATION_SCHEMA.COLUMNS ... */
@Override
public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException, ForemanSetupException {
  SqlDescribeTable node = unwrap(sqlNode, SqlDescribeTable.class);

  try {
    List<SqlNode> selectList =
        ImmutableList.of((SqlNode) new SqlIdentifier(COLS_COL_COLUMN_NAME, SqlParserPos.ZERO),
                                   new SqlIdentifier(COLS_COL_DATA_TYPE, SqlParserPos.ZERO),
                                   new SqlIdentifier(COLS_COL_IS_NULLABLE, SqlParserPos.ZERO));

    SqlNode fromClause = new SqlIdentifier(
        ImmutableList.of(IS_SCHEMA_NAME, TAB_COLUMNS), null, SqlParserPos.ZERO, null);

    final SqlIdentifier table = node.getTable();
    final SchemaPlus defaultSchema = context.getNewDefaultSchema();
    final List<String> schemaPathGivenInCmd = Util.skipLast(table.names);
    final SchemaPlus schema = SchemaUtilites.findSchema(defaultSchema, schemaPathGivenInCmd);

    if (schema == null) {
      SchemaUtilites.throwSchemaNotFoundException(defaultSchema,
          SchemaUtilites.SCHEMA_PATH_JOINER.join(schemaPathGivenInCmd));
    }

    if (SchemaUtilites.isRootSchema(schema)) {
      throw UserException.validationError()
          .message("No schema selected.")
          .build(logger);
    }

    final String tableName = Util.last(table.names);

    // find resolved schema path
    final String schemaPath = SchemaUtilites.unwrapAsDrillSchemaInstance(schema).getFullSchemaName();

    if (schema.getTable(tableName) == null) {
      throw UserException.validationError()
          .message("Unknown table [%s] in schema [%s]", tableName, schemaPath)
          .build(logger);
    }

    SqlNode schemaCondition = null;
    if (!SchemaUtilites.isRootSchema(schema)) {
      schemaCondition = DrillParserUtil.createCondition(
          new SqlIdentifier(SHRD_COL_TABLE_SCHEMA, SqlParserPos.ZERO),
          SqlStdOperatorTable.EQUALS,
          SqlLiteral.createCharString(schemaPath, CHARSET, SqlParserPos.ZERO)
      );
    }

    SqlNode where = DrillParserUtil.createCondition(
        new SqlIdentifier(SHRD_COL_TABLE_NAME, SqlParserPos.ZERO),
        SqlStdOperatorTable.EQUALS,
        SqlLiteral.createCharString(tableName, CHARSET, SqlParserPos.ZERO));

    where = DrillParserUtil.createCondition(schemaCondition, SqlStdOperatorTable.AND, where);

    SqlNode columnFilter = null;
    if (node.getColumn() != null) {
      columnFilter =
          DrillParserUtil.createCondition(
              new SqlIdentifier(COLS_COL_COLUMN_NAME, SqlParserPos.ZERO),
              SqlStdOperatorTable.EQUALS,
              SqlLiteral.createCharString(node.getColumn().toString(), CHARSET, SqlParserPos.ZERO));
    } else if (node.getColumnQualifier() != null) {
      columnFilter =
          DrillParserUtil.createCondition(
              new SqlIdentifier(COLS_COL_COLUMN_NAME, SqlParserPos.ZERO),
              SqlStdOperatorTable.LIKE, node.getColumnQualifier());
    }

    where = DrillParserUtil.createCondition(where, SqlStdOperatorTable.AND, columnFilter);

    return new SqlSelect(SqlParserPos.ZERO, null, new SqlNodeList(selectList, SqlParserPos.ZERO),
        fromClause, where, null, null, null, null, null, null);
  } catch (Exception ex) {
    throw UserException.planError(ex)
        .message("Error while rewriting DESCRIBE query: %d", ex.getMessage())
        .build(logger);
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:81,代码来源:DescribeTableHandler.java

示例10: HiveUDFOperator

public HiveUDFOperator(String name) {
  super(new SqlIdentifier(name, SqlParserPos.ZERO), DynamicReturnType.INSTANCE, null, new ArgChecker(), null,
      SqlFunctionCategory.USER_DEFINED_FUNCTION);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:4,代码来源:HiveUDFOperator.java

示例11: VarArgSqlOperator

public VarArgSqlOperator(String name, MajorType returnType, boolean isDeterministic) {
  super(new SqlIdentifier(name, SqlParserPos.ZERO), DynamicReturnType.INSTANCE, null, new Checker(), null, SqlFunctionCategory.USER_DEFINED_FUNCTION);
  this.returnType = returnType;
  this.isDeterministic = isDeterministic;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:VarArgSqlOperator.java

示例12: SqlFlattenOperator

public SqlFlattenOperator(int index) {
  super(new SqlIdentifier("FLATTEN", SqlParserPos.ZERO), DynamicReturnType.INSTANCE, null, OperandTypes.ANY, null, SqlFunctionCategory.USER_DEFINED_FUNCTION);
  this.index = index;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:4,代码来源:SqlFlattenOperator.java

示例13: HiveUDFOperator

public HiveUDFOperator(String name, SqlReturnTypeInference sqlReturnTypeInference) {
  super(new SqlIdentifier(name, SqlParserPos.ZERO), sqlReturnTypeInference, null, ArgChecker.INSTANCE, null,
      SqlFunctionCategory.USER_DEFINED_FUNCTION);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:4,代码来源:HiveUDFOperator.java


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