Java Code Examples for org.apache.calcite.sql.SqlCall#accept()

The following examples show how to use org.apache.calcite.sql.SqlCall#accept() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AggChecker.java    From Bats with Apache License 2.0 5 votes vote down vote up
public Void visit(SqlIdentifier id) {
  if (isGroupExpr(id) || id.isStar()) {
    // Star may validly occur in "SELECT COUNT(*) OVER w"
    return null;
  }

  // Is it a call to a parentheses-free function?
  SqlCall call =
      SqlUtil.makeCall(
          validator.getOperatorTable(),
          id);
  if (call != null) {
    return call.accept(this);
  }

  // Didn't find the identifier in the group-by list as is, now find
  // it fully-qualified.
  // TODO: It would be better if we always compared fully-qualified
  // to fully-qualified.
  final SqlQualified fqId = scopes.peek().fullyQualify(id);
  if (isGroupExpr(fqId.identifier)) {
    return null;
  }
  SqlNode originalExpr = validator.getOriginal(id);
  final String exprString = originalExpr.toString();
  throw validator.newValidationError(originalExpr,
      distinct
          ? RESOURCE.notSelectDistinctExpr(exprString)
          : RESOURCE.notGroupExpr(exprString));
}
 
Example 2
Source File: SqlValidatorImpl.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override public SqlNode visit(SqlIdentifier id) {
	// First check for builtin functions which don't have
	// parentheses, like "LOCALTIME".
	SqlCall call =
		SqlUtil.makeCall(
			validator.getOperatorTable(),
			id);
	if (call != null) {
		return call.accept(this);
	}
	final SqlIdentifier fqId = getScope().fullyQualify(id).identifier;
	SqlNode expandedExpr = fqId;
	// Convert a column ref into ITEM(*, 'col_name').
	// select col_name from (select * from dynTable)
	// SqlIdentifier "col_name" would be resolved to a dynamic star field in dynTable's rowType.
	// Expand such SqlIdentifier to ITEM operator.
	if (DynamicRecordType.isDynamicStarColName(Util.last(fqId.names))
		&& !DynamicRecordType.isDynamicStarColName(Util.last(id.names))) {
		SqlNode[] inputs = new SqlNode[2];
		inputs[0] = fqId;
		inputs[1] = SqlLiteral.createCharString(
			Util.last(id.names),
			id.getParserPosition());
		SqlBasicCall item_call = new SqlBasicCall(
			SqlStdOperatorTable.ITEM,
			inputs,
			id.getParserPosition());
		expandedExpr = item_call;
	}
	validator.setOriginal(expandedExpr, id);
	return expandedExpr;
}
 
Example 3
Source File: SqlValidatorImpl.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override public SqlNode visit(SqlIdentifier id) {
	// First check for builtin functions which don't have
	// parentheses, like "LOCALTIME".
	final SqlCall call = validator.makeNullaryCall(id);
	if (call != null) {
		return call.accept(this);
	}
	final SqlIdentifier fqId = getScope().fullyQualify(id).identifier;
	SqlNode expandedExpr = expandDynamicStar(id, fqId);
	validator.setOriginal(expandedExpr, id);
	return expandedExpr;
}
 
Example 4
Source File: AggChecker.java    From calcite with Apache License 2.0 5 votes vote down vote up
public Void visit(SqlIdentifier id) {
  if (isGroupExpr(id) || id.isStar()) {
    // Star may validly occur in "SELECT COUNT(*) OVER w"
    return null;
  }

  // Is it a call to a parentheses-free function?
  final SqlCall call = validator.makeNullaryCall(id);
  if (call != null) {
    return call.accept(this);
  }

  // Didn't find the identifier in the group-by list as is, now find
  // it fully-qualified.
  // TODO: It would be better if we always compared fully-qualified
  // to fully-qualified.
  final SqlQualified fqId = scopes.peek().fullyQualify(id);
  if (isGroupExpr(fqId.identifier)) {
    return null;
  }
  SqlNode originalExpr = validator.getOriginal(id);
  final String exprString = originalExpr.toString();
  throw validator.newValidationError(originalExpr,
      distinct
          ? RESOURCE.notSelectDistinctExpr(exprString)
          : RESOURCE.notGroupExpr(exprString));
}