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

Java SqlValidatorScope类代码示例

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

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



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

示例1: makeNullableIfOperandsAre

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的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


示例2: getMonotonicity

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
public SqlMonotonicity getMonotonicity(SqlValidatorScope scope) {
  // for "star" column, whether it's static or dynamic return not_monotonic directly.
  if (Util.last(names).equals("") || DynamicRecordType.isDynamicStarColName(Util.last(names))) {
    return SqlMonotonicity.NOT_MONOTONIC;
  }

  // First check for builtin functions which don't have parentheses,
  // like "LOCALTIME".
  final SqlValidator validator = scope.getValidator();
  SqlCall call =
      SqlUtil.makeCall(
          validator.getOperatorTable(),
          this);
  if (call != null) {
    return call.getMonotonicity(scope);
  }
  final SqlQualified qualified = scope.fullyQualify(this);
  final SqlIdentifier fqId = qualified.identifier;
  return qualified.namespace.resolve().getMonotonicity(Util.last(fqId.names));
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:SqlIdentifier.java


示例3: validateCall

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
public void validateCall(
    SqlCall call,
    SqlValidator validator,
    SqlValidatorScope scope,
    SqlValidatorScope operandScope) {
  // The base method validates all operands. We override because
  // we don't want to validate the identifier.
  final List<SqlNode> operands = call.getOperandList();
  assert operands.size() == 2;
  assert operands.get(1) instanceof SqlIdentifier;
  operands.get(0).validateExpr(validator, scope);
  SqlIdentifier id = (SqlIdentifier) operands.get(1);
  if (!id.isSimple()) {
    throw validator.newValidationError(id,
        RESOURCE.aliasMustBeSimpleIdentifier());
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:SqlAsOperator.java


示例4: deriveType

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
/**
 * Calls the parent class method and mask Farrago exception thrown.
 */
public RelDataType deriveType(
    SqlValidatorScope scope,
    SqlNode operand) {
  // REVIEW Do not mask Error (indicates a serious system problem) or
  // UnsupportedOperationException (a bug). I have to mask
  // UnsupportedOperationException because
  // SqlValidatorImpl.getValidatedNodeType throws it for an unrecognized
  // identifier node I have to mask Error as well because
  // AbstractNamespace.getRowType  called in super.deriveType can do a
  // Util.permAssert that throws Error
  try {
    return super.deriveType(scope, operand);
  } catch (CalciteException | UnsupportedOperationException | Error e) {
    return unknownType;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:SqlAdvisorValidator.java


示例5: validateExpr

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
public void validateExpr(SqlValidator validator, SqlValidatorScope scope) {
  // While a SqlNodeList is not always a valid expression, this
  // implementation makes that assumption. It just validates the members
  // of the list.
  //
  // One example where this is valid is the IN operator. The expression
  //
  //    empno IN (10, 20)
  //
  // results in a call with operands
  //
  //    {  SqlIdentifier({"empno"}),
  //       SqlNodeList(SqlLiteral(10), SqlLiteral(20))  }

  for (SqlNode node : list) {
    node.validateExpr(validator, scope);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:SqlNodeList.java


示例6: validateCall

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
public void validateCall(
    SqlCall call,
    SqlValidator validator,
    SqlValidatorScope scope,
    SqlValidatorScope operandScope) {
  assert call.getOperator() == this;
  assert call.operandCount() == 2;
  SqlCall aggCall = call.operand(0);
  if (!aggCall.getOperator().isAggregator()) {
    throw validator.newValidationError(aggCall,
        RESOURCE.filterNonAggregate());
  }
  final SqlNode condition = call.operand(1);
  validator.validateAggregateParams(aggCall, condition, scope);

  final RelDataType type = validator.deriveType(scope, condition);
  if (!SqlTypeUtil.inBooleanFamily(type)) {
    throw validator.newValidationError(condition,
        RESOURCE.condMustBeBoolean("FILTER"));
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:SqlFilterOperator.java


示例7: validateCall

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
public void validateCall(
    SqlCall call,
    SqlValidator validator,
    SqlValidatorScope scope,
    SqlValidatorScope operandScope) {
  // per the SQL std, each string fragment must be on a different line
  final List<SqlNode> operandList = call.getOperandList();
  for (int i = 1; i < operandList.size(); i++) {
    SqlParserPos prevPos = operandList.get(i - 1).getParserPosition();
    final SqlNode operand = operandList.get(i);
    SqlParserPos pos = operand.getParserPosition();
    if (pos.getLineNum() <= prevPos.getLineNum()) {
      throw validator.newValidationError(operand,
          RESOURCE.stringFragsOnSameLine());
    }
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:SqlLiteralChainOperator.java


示例8: deriveType

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
@Override public RelDataType deriveType(SqlValidator validator,
    SqlValidatorScope scope, SqlCall call) {
  RelDataType nodeType = validator.deriveType(scope, call.getOperandList().get(0));
  assert nodeType != null;

  final String fieldName = call.getOperandList().get(1).toString();
  RelDataTypeField field =
      nodeType.getField(fieldName, false, false);
  if (field == null) {
    throw SqlUtil.newContextException(SqlParserPos.ZERO, Static.RESOURCE.unknownField(fieldName));
  }
  RelDataType type = field.getType();

  // Validate and determine coercibility and resulting collation
  // name of binary operator if needed.
  type = adjustType(validator, call, type);
  SqlValidatorUtil.checkCharsetAndCollateConsistentIfCharType(type);
  return type;
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:SqlDotOperator.java


示例9: validateCall

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
public void validateCall(
    SqlCall call,
    SqlValidator validator,
    SqlValidatorScope scope,
    SqlValidatorScope operandScope) {
  // This implementation looks for the quantifier keywords DISTINCT or
  // ALL as the first operand in the list.  If found then the literal is
  // not called to validate itself.  Further the function is checked to
  // make sure that a quantifier is valid for that particular function.
  //
  // If the first operand does not appear to be a quantifier then the
  // parent ValidateCall is invoked to do normal function validation.

  super.validateCall(call, validator, scope, operandScope);
  validateQuantifier(validator, call);
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:SqlFunction.java


示例10: findValidOptions

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
public void findValidOptions(
    SqlValidator validator,
    SqlValidatorScope scope,
    SqlParserPos pos,
    Collection<SqlMoniker> hintList) {
  for (SqlNode operand : getOperandList()) {
    if (operand instanceof SqlIdentifier) {
      SqlIdentifier id = (SqlIdentifier) operand;
      SqlParserPos idPos = id.getParserPosition();
      if (idPos.toString().equals(pos.toString())) {
        ((SqlValidatorImpl) validator).lookupNameCompletionHints(
            scope, id.names, pos, hintList);
        return;
      }
    }
  }
  // no valid options
}
 
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:SqlCall.java


示例11: validateOperands

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
/**
 * Validates the operands of a call, inferring the return type in the
 * process.
 *
 * @param validator active validator
 * @param scope     validation scope
 * @param call      call to be validated
 * @return inferred type
 */
public final RelDataType validateOperands(
    SqlValidator validator,
    SqlValidatorScope scope,
    SqlCall call) {
  // Let subclasses know what's up.
  preValidateCall(validator, scope, call);

  // Check the number of operands
  checkOperandCount(validator, operandTypeChecker, call);

  SqlCallBinding opBinding = new SqlCallBinding(validator, scope, call);

  checkOperandTypes(
      opBinding,
      true);

  // Now infer the result type.
  RelDataType ret = inferReturnType(opBinding);
  ((SqlValidatorImpl) validator).setValidatedNodeType(call, ret);
  return ret;
}
 
开发者ID:apache,项目名称:calcite,代码行数:31,代码来源:SqlOperator.java


示例12: makeNullableIfOperandsAre

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的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


示例13: deriveType

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
@Override
public RelDataType deriveType(SqlValidator validator, SqlValidatorScope scope, SqlCall call) {
  if (NONE.equals(returnType)) {
    return validator.getTypeFactory().createSqlType(SqlTypeName.ANY);
  }
  /*
   * We return a nullable output type both in validation phase and in
   * Sql to Rel phase. We don't know the type of the output until runtime
   * hence have to choose the least restrictive type to avoid any wrong
   * results.
   */
  return getNullableReturnDataType(validator.getTypeFactory());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:14,代码来源:DrillSqlOperator.java


示例14: convertSelect

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
/**
 * Converts a SELECT statement's parse tree into a relational expression.
 */
public RelNode convertSelect(SqlSelect select, boolean top) {
	final SqlValidatorScope selectScope = validator.getWhereScope(select);
	final Blackboard bb = createBlackboard(selectScope, null, top);
	convertSelectImpl(bb, select);
	return bb.root;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:SqlToRelConverter.java


示例15: isSubQueryNonCorrelated

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
/**
 * Determines whether a sub-query is non-correlated. Note that a
 * non-correlated sub-query can contain correlated references, provided those
 * references do not reference select statements that are parents of the
 * sub-query.
 *
 * @param subq the sub-query
 * @param bb   blackboard used while converting the sub-query, i.e., the
 *             blackboard of the parent query of this sub-query
 * @return true if the sub-query is non-correlated
 */
private boolean isSubQueryNonCorrelated(RelNode subq, Blackboard bb) {
	Set<CorrelationId> correlatedVariables = RelOptUtil.getVariablesUsed(subq);
	for (CorrelationId correlName : correlatedVariables) {
		DeferredLookup lookup = mapCorrelToDeferred.get(correlName);
		String originalRelName = lookup.getOriginalRelName();

		final SqlNameMatcher nameMatcher =
			lookup.bb.scope.getValidator().getCatalogReader().nameMatcher();
		final SqlValidatorScope.ResolvedImpl resolved =
			new SqlValidatorScope.ResolvedImpl();
		lookup.bb.scope.resolve(ImmutableList.of(originalRelName), nameMatcher,
			false, resolved);

		SqlValidatorScope ancestorScope = resolved.only().scope;

		// If the correlated reference is in a scope that's "above" the
		// sub-query, then this is a correlated sub-query.
		SqlValidatorScope parentScope = bb.scope;
		do {
			if (ancestorScope == parentScope) {
				return false;
			}
			if (parentScope instanceof DelegatingScope) {
				parentScope = ((DelegatingScope) parentScope).getParent();
			} else {
				break;
			}
		} while (parentScope != null);
	}
	return true;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:43,代码来源:SqlToRelConverter.java


示例16: deriveType

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
@Override
public RelDataType deriveType(
    SqlValidator validator,
    SqlValidatorScope scope,
    SqlCall call) {
  return operator.deriveType(validator,
      scope,
      call);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:10,代码来源:DrillCalciteSqlFunctionWrapper.java


示例17: convertSelect

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
/**
 * Converts a SELECT statement's parse tree into a relational expression.
 */
public RelNode convertSelect(SqlSelect select, boolean top) {
  final SqlValidatorScope selectScope = validator.getWhereScope(select);
  final Blackboard bb = createBlackboard(selectScope, null, top);
  convertSelectImpl(bb, select);
  return bb.root;
}
 
开发者ID:apache,项目名称:kylin,代码行数:10,代码来源:SqlToRelConverter.java


示例18: isSubQueryNonCorrelated

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
/**
 * Determines whether a sub-query is non-correlated. Note that a
 * non-correlated sub-query can contain correlated references, provided those
 * references do not reference select statements that are parents of the
 * sub-query.
 *
 * @param subq the sub-query
 * @param bb   blackboard used while converting the sub-query, i.e., the
 *             blackboard of the parent query of this sub-query
 * @return true if the sub-query is non-correlated
 */
private boolean isSubQueryNonCorrelated(RelNode subq, Blackboard bb) {
  Set<CorrelationId> correlatedVariables = RelOptUtil.getVariablesUsed(subq);
  for (CorrelationId correlName : correlatedVariables) {
    DeferredLookup lookup = mapCorrelToDeferred.get(correlName);
    String originalRelName = lookup.getOriginalRelName();

    final SqlNameMatcher nameMatcher =
        lookup.bb.scope.getValidator().getCatalogReader().nameMatcher();
    final SqlValidatorScope.ResolvedImpl resolved =
        new SqlValidatorScope.ResolvedImpl();
    lookup.bb.scope.resolve(ImmutableList.of(originalRelName), nameMatcher,
        false, resolved);

    SqlValidatorScope ancestorScope = resolved.only().scope;

    // If the correlated reference is in a scope that's "above" the
    // sub-query, then this is a correlated sub-query.
    SqlValidatorScope parentScope = bb.scope;
    do {
      if (ancestorScope == parentScope) {
        return false;
      }
      if (parentScope instanceof DelegatingScope) {
        parentScope = ((DelegatingScope) parentScope).getParent();
      } else {
        break;
      }
    } while (parentScope != null);
  }
  return true;
}
 
开发者ID:apache,项目名称:kylin,代码行数:43,代码来源:SqlToRelConverter.java


示例19: deriveAndCollectTypes

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
/**
 * Iterates over all operands, derives their types, and collects them into
 * a list.
 */
public static List<RelDataType> deriveAndCollectTypes(
        SqlValidator validator,
        SqlValidatorScope scope,
        List<SqlNode> operands) {
    // NOTE: Do not use an AbstractList. Don't want to be lazy. We want
    // errors.
    List<RelDataType> types = new ArrayList<RelDataType>();
    for (SqlNode operand : operands) {
        types.add(validator.deriveType(scope, operand));
    }
    return types;
}
 
开发者ID:apache,项目名称:kylin,代码行数:17,代码来源:SqlTypeUtil.java


示例20: validateCall

import org.apache.calcite.sql.validate.SqlValidatorScope; //导入依赖的package包/类
public void validateCall(
    SqlCall call,
    SqlValidator validator,
    SqlValidatorScope scope,
    SqlValidatorScope operandScope) {
  validator.validateQuery(call, operandScope, validator.getUnknownType());
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:SqlSetOperator.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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