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

The following examples show how to use org.apache.calcite.sql.SqlCall#getKind() . 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: DremioSqlDialect.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
@Override
public void unparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) {
  // Translate the PI function call to PI()
  if (call.getOperator() == SqlStdOperatorTable.PI) {
    super.unparseCall(
      writer,
      PI_FUNCTION.createCall(new SqlNodeList(call.getOperandList(), SqlParserPos.ZERO)),
      leftPrec, rightPrec);
  } else if (call.getOperator().equals(FunctionRegistry.E_FUNCTION)) {
    // Translate the E() function call to EXP(1)
    final SqlCall newCall = SqlStdOperatorTable.EXP.createCall(
      SqlParserPos.ZERO, SqlLiteral.createExactNumeric("1", SqlParserPos.ZERO));
    super.unparseCall(writer, newCall, leftPrec, rightPrec);
  } else if (call.getKind() == SqlKind.JOIN) {
    this.unparseJoin(writer, (SqlJoin) call, leftPrec, rightPrec);
  } else {
    super.unparseCall(writer, call, leftPrec, rightPrec);
  }
}
 
Example 2
Source File: SqlValidatorImpl.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override protected SqlNode visitScoped(SqlCall call) {
	switch (call.getKind()) {
		case SCALAR_QUERY:
		case CURRENT_VALUE:
		case NEXT_VALUE:
		case WITH:
			return call;
	}
	// Only visits arguments which are expressions. We don't want to
	// qualify non-expressions such as 'x' in 'empno * 5 AS x'.
	ArgHandler<SqlNode> argHandler =
		new CallCopyingArgHandler(call, false);
	call.getOperator().acceptCall(this, call, true, argHandler);
	final SqlNode result = argHandler.result();
	validator.setOriginal(result, call);
	return result;
}
 
Example 3
Source File: SqlValidatorImpl.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override public SqlNode visit(SqlCall call) {
	SqlKind kind = call.getKind();
	if (isLogicalNavigation(kind)
		|| isAggregation(kind)
		|| isRunningOrFinal(kind)) {
		return call;
	}

	switch (kind) {
		case PREV:
			final List<SqlNode> operands = call.getOperandList();
			if (operands.get(0) instanceof SqlIdentifier) {
				String name = ((SqlIdentifier) operands.get(0)).names.get(0);
				return name.equals(alpha) ? call
					: SqlStdOperatorTable.LAST.createCall(SqlParserPos.ZERO, operands);
			}
	}
	return super.visit(call);
}
 
Example 4
Source File: SqlValidatorImpl.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override protected SqlNode visitScoped(SqlCall call) {
	switch (call.getKind()) {
		case SCALAR_QUERY:
		case CURRENT_VALUE:
		case NEXT_VALUE:
		case WITH:
			return call;
	}
	// Only visits arguments which are expressions. We don't want to
	// qualify non-expressions such as 'x' in 'empno * 5 AS x'.
	ArgHandler<SqlNode> argHandler =
		new CallCopyingArgHandler(call, false);
	call.getOperator().acceptCall(this, call, true, argHandler);
	final SqlNode result = argHandler.result();
	validator.setOriginal(result, call);
	return result;
}
 
Example 5
Source File: MysqlSqlDialect.java    From calcite with Apache License 2.0 6 votes vote down vote up
@Override public void unparseCall(SqlWriter writer, SqlCall call,
    int leftPrec, int rightPrec) {
  switch (call.getKind()) {
  case FLOOR:
    if (call.operandCount() != 2) {
      super.unparseCall(writer, call, leftPrec, rightPrec);
      return;
    }

    unparseFloor(writer, call);
    break;

  default:
    super.unparseCall(writer, call, leftPrec, rightPrec);
  }
}
 
Example 6
Source File: HsqldbSqlDialect.java    From Bats with Apache License 2.0 6 votes vote down vote up
@Override public void unparseCall(SqlWriter writer, SqlCall call,
    int leftPrec, int rightPrec) {
  switch (call.getKind()) {
  case FLOOR:
    if (call.operandCount() != 2) {
      super.unparseCall(writer, call, leftPrec, rightPrec);
      return;
    }

    final SqlLiteral timeUnitNode = call.operand(1);
    final TimeUnitRange timeUnit = timeUnitNode.getValueAs(TimeUnitRange.class);

    final String translatedLit = convertTimeUnit(timeUnit);
    SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, translatedLit,
        timeUnitNode.getParserPosition());
    SqlFloorFunction.unparseDatetimeFunction(writer, call2, "TRUNC", true);
    break;

  default:
    super.unparseCall(writer, call, leftPrec, rightPrec);
  }
}
 
Example 7
Source File: MysqlSqlDialect.java    From Bats with Apache License 2.0 6 votes vote down vote up
@Override public void unparseCall(SqlWriter writer, SqlCall call,
    int leftPrec, int rightPrec) {
  switch (call.getKind()) {
  case FLOOR:
    if (call.operandCount() != 2) {
      super.unparseCall(writer, call, leftPrec, rightPrec);
      return;
    }

    unparseFloor(writer, call);
    break;

  default:
    super.unparseCall(writer, call, leftPrec, rightPrec);
  }
}
 
Example 8
Source File: PostgresqlSqlDialect.java    From Bats with Apache License 2.0 6 votes vote down vote up
@Override public void unparseCall(SqlWriter writer, SqlCall call,
    int leftPrec, int rightPrec) {
  switch (call.getKind()) {
  case FLOOR:
    if (call.operandCount() != 2) {
      super.unparseCall(writer, call, leftPrec, rightPrec);
      return;
    }

    final SqlLiteral timeUnitNode = call.operand(1);
    final TimeUnitRange timeUnit = timeUnitNode.getValueAs(TimeUnitRange.class);

    SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, timeUnit.name(),
        timeUnitNode.getParserPosition());
    SqlFloorFunction.unparseDatetimeFunction(writer, call2, "DATE_TRUNC", false);
    break;

  default:
    super.unparseCall(writer, call, leftPrec, rightPrec);
  }
}
 
Example 9
Source File: SparkSqlDialect.java    From calcite with Apache License 2.0 5 votes vote down vote up
@Override public void unparseCall(SqlWriter writer, SqlCall call,
    int leftPrec, int rightPrec) {
  if (call.getOperator() == SqlStdOperatorTable.SUBSTRING) {
    SqlUtil.unparseFunctionSyntax(SPARKSQL_SUBSTRING, writer, call);
  } else {
    switch (call.getKind()) {
    case FLOOR:
      if (call.operandCount() != 2) {
        super.unparseCall(writer, call, leftPrec, rightPrec);
        return;
      }

      final SqlLiteral timeUnitNode = call.operand(1);
      final TimeUnitRange timeUnit = timeUnitNode.getValueAs(TimeUnitRange.class);

      SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, timeUnit.name(),
          timeUnitNode.getParserPosition());
      SqlFloorFunction.unparseDatetimeFunction(writer, call2, "DATE_TRUNC", false);
      break;
    case TRIM:
      unparseHiveTrim(writer, call, leftPrec, rightPrec);
      break;
    default:
      super.unparseCall(writer, call, leftPrec, rightPrec);
    }
  }
}
 
Example 10
Source File: ClickHouseSqlDialect.java    From calcite with Apache License 2.0 5 votes vote down vote up
@Override public void unparseCall(SqlWriter writer, SqlCall call,
    int leftPrec, int rightPrec) {
  if (call.getOperator() == SqlStdOperatorTable.SUBSTRING) {
    RelToSqlConverterUtil.specialOperatorByName("substring")
        .unparse(writer, call, 0, 0);
  } else {
    switch (call.getKind()) {
    case FLOOR:
      if (call.operandCount() != 2) {
        super.unparseCall(writer, call, leftPrec, rightPrec);
        return;
      }

      unparseFloor(writer, call);
      break;

    case COUNT:
      // CH returns NULL rather than 0 for COUNT(DISTINCT) of NULL values.
      // https://github.com/yandex/ClickHouse/issues/2494
      // Wrap the call in a CH specific coalesce (assumeNotNull).
      if (call.getFunctionQuantifier() != null
          && call.getFunctionQuantifier().toString().equals("DISTINCT")) {
        writer.print("assumeNotNull");
        SqlWriter.Frame frame = writer.startList("(", ")");
        super.unparseCall(writer, call, leftPrec, rightPrec);
        writer.endList(frame);
      } else {
        super.unparseCall(writer, call, leftPrec, rightPrec);
      }
      break;

    default:
      super.unparseCall(writer, call, leftPrec, rightPrec);
    }
  }
}
 
Example 11
Source File: HiveSqlDialect.java    From calcite with Apache License 2.0 5 votes vote down vote up
@Override public void unparseCall(final SqlWriter writer, final SqlCall call,
    final int leftPrec, final int rightPrec) {
  switch (call.getKind()) {
  case POSITION:
    final SqlWriter.Frame frame = writer.startFunCall("INSTR");
    writer.sep(",");
    call.operand(1).unparse(writer, leftPrec, rightPrec);
    writer.sep(",");
    call.operand(0).unparse(writer, leftPrec, rightPrec);
    if (3 == call.operandCount()) {
      throw new RuntimeException("3rd operand Not Supported for Function INSTR in Hive");
    }
    writer.endFunCall(frame);
    break;
  case MOD:
    SqlOperator op = SqlStdOperatorTable.PERCENT_REMAINDER;
    SqlSyntax.BINARY.unparse(writer, op, call, leftPrec, rightPrec);
    break;
  case TRIM:
    RelToSqlConverterUtil.unparseHiveTrim(writer, call, leftPrec, rightPrec);
    break;
  case OTHER_FUNCTION:
    if (call.getOperator() instanceof SqlSubstringFunction) {
      final SqlWriter.Frame funCallFrame = writer.startFunCall(call.getOperator().getName());
      call.operand(0).unparse(writer, leftPrec, rightPrec);
      writer.sep(",", true);
      call.operand(1).unparse(writer, leftPrec, rightPrec);
      if (3 == call.operandCount()) {
        writer.sep(",", true);
        call.operand(2).unparse(writer, leftPrec, rightPrec);
      }
      writer.endFunCall(funCallFrame);
    } else {
      super.unparseCall(writer, call, leftPrec, rightPrec);
    }
    break;
  default:
    super.unparseCall(writer, call, leftPrec, rightPrec);
  }
}
 
Example 12
Source File: Util.java    From Bats with Apache License 2.0 4 votes vote down vote up
@Override public Void visit(SqlCall call) {
  if (call.getKind() == SqlKind.OVER) {
    throw FoundOne.NULL;
  }
  return super.visit(call);
}
 
Example 13
Source File: AggVisitor.java    From calcite with Apache License 2.0 4 votes vote down vote up
public Void visit(SqlCall call) {
  final SqlOperator operator = call.getOperator();
  // If nested aggregates disallowed or found an aggregate at invalid level
  if (operator.isAggregator()
      && !(operator instanceof SqlAbstractGroupFunction)
      && !operator.requiresOver()) {
    if (delegate != null) {
      return operator.acceptCall(delegate, call);
    }
    if (aggregate) {
      return found(call);
    }
  }
  if (group && operator.isGroup()) {
    return found(call);
  }
  // User-defined function may not be resolved yet.
  if (operator instanceof SqlFunction) {
    final SqlFunction sqlFunction = (SqlFunction) operator;
    if (sqlFunction.getFunctionType().isUserDefinedNotSpecificFunction()) {
      final List<SqlOperator> list = new ArrayList<>();
      opTab.lookupOperatorOverloads(sqlFunction.getSqlIdentifier(),
          sqlFunction.getFunctionType(), SqlSyntax.FUNCTION, list,
          nameMatcher);
      for (SqlOperator operator2 : list) {
        if (operator2.isAggregator() && !operator2.requiresOver()) {
          // If nested aggregates disallowed or found aggregate at invalid
          // level
          if (aggregate) {
            found(call);
          }
        }
      }
    }
  }
  if (call.isA(SqlKind.QUERY)) {
    // don't traverse into queries
    return null;
  }
  if (call.getKind() == SqlKind.WITHIN_GROUP) {
    if (aggregate) {
      return found(call);
    }
  }
  if (call.getKind() == SqlKind.OVER) {
    if (over) {
      return found(call);
    } else {
      // an aggregate function over a window is not an aggregate!
      return null;
    }
  }
  return super.visit(call);
}
 
Example 14
Source File: BigQuerySqlDialect.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Override public void unparseCall(final SqlWriter writer, final SqlCall call, final int leftPrec,
    final int rightPrec) {
  switch (call.getKind()) {
  case POSITION:
    final SqlWriter.Frame frame = writer.startFunCall("STRPOS");
    writer.sep(",");
    call.operand(1).unparse(writer, leftPrec, rightPrec);
    writer.sep(",");
    call.operand(0).unparse(writer, leftPrec, rightPrec);
    if (3 == call.operandCount()) {
      throw new RuntimeException("3rd operand Not Supported for Function STRPOS in Big Query");
    }
    writer.endFunCall(frame);
    break;
  case UNION:
    if (((SqlSetOperator) call.getOperator()).isAll()) {
      super.unparseCall(writer, call, leftPrec, rightPrec);
    } else {
      SqlSyntax.BINARY.unparse(writer, UNION_DISTINCT, call, leftPrec,
          rightPrec);
    }
    break;
  case EXCEPT:
    if (((SqlSetOperator) call.getOperator()).isAll()) {
      throw new RuntimeException("BigQuery does not support EXCEPT ALL");
    }
    SqlSyntax.BINARY.unparse(writer, EXCEPT_DISTINCT, call, leftPrec,
        rightPrec);
    break;
  case INTERSECT:
    if (((SqlSetOperator) call.getOperator()).isAll()) {
      throw new RuntimeException("BigQuery does not support INTERSECT ALL");
    }
    SqlSyntax.BINARY.unparse(writer, INTERSECT_DISTINCT, call, leftPrec,
        rightPrec);
    break;
  case TRIM:
    unparseTrim(writer, call, leftPrec, rightPrec);
    break;
  default:
    super.unparseCall(writer, call, leftPrec, rightPrec);
  }
}
 
Example 15
Source File: SqlValidatorImpl.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override public SqlNode visit(SqlCall call) {
	SqlKind kind = call.getKind();
	List<SqlNode> operands = call.getOperandList();
	List<SqlNode> newOperands = new ArrayList<>();

	// This code is a workaround for CALCITE-2707
	if (call.getFunctionQuantifier() != null
		&& call.getFunctionQuantifier().getValue() == SqlSelectKeyword.DISTINCT) {
		final SqlParserPos pos = call.getParserPosition();
		throw SqlUtil.newContextException(pos, Static.RESOURCE.functionQuantifierNotAllowed(call.toString()));
	}
	// This code is a workaround for CALCITE-2707

	if (isLogicalNavigation(kind) || isPhysicalNavigation(kind)) {
		SqlNode inner = operands.get(0);
		SqlNode offset = operands.get(1);

		// merge two straight prev/next, update offset
		if (isPhysicalNavigation(kind)) {
			SqlKind innerKind = inner.getKind();
			if (isPhysicalNavigation(innerKind)) {
				List<SqlNode> innerOperands = ((SqlCall) inner).getOperandList();
				SqlNode innerOffset = innerOperands.get(1);
				SqlOperator newOperator = innerKind == kind
					? SqlStdOperatorTable.PLUS : SqlStdOperatorTable.MINUS;
				offset = newOperator.createCall(SqlParserPos.ZERO,
					offset, innerOffset);
				inner = call.getOperator().createCall(SqlParserPos.ZERO,
					innerOperands.get(0), offset);
			}
		}
		SqlNode newInnerNode =
			inner.accept(new NavigationExpander(call.getOperator(), offset));
		if (op != null) {
			newInnerNode = op.createCall(SqlParserPos.ZERO, newInnerNode,
				this.offset);
		}
		return newInnerNode;
	}

	if (operands.size() > 0) {
		for (SqlNode node : operands) {
			if (node != null) {
				SqlNode newNode = node.accept(new NavigationExpander());
				if (op != null) {
					newNode = op.createCall(SqlParserPos.ZERO, newNode, offset);
				}
				newOperands.add(newNode);
			} else {
				newOperands.add(null);
			}
		}
		return call.getOperator().createCall(SqlParserPos.ZERO, newOperands);
	} else {
		if (op == null) {
			return call;
		} else {
			return op.createCall(SqlParserPos.ZERO, call, offset);
		}
	}
}
 
Example 16
Source File: SqlValidatorImpl.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override public Set<String> visit(SqlCall call) {
	boolean isSingle = false;
	Set<String> vars = new HashSet<>();
	SqlKind kind = call.getKind();
	List<SqlNode> operands = call.getOperandList();

	if (isSingleVarRequired(kind)) {
		isSingle = true;
		if (isPhysicalNavigation(kind)) {
			if (isMeasure) {
				throw newValidationError(call,
					Static.RESOURCE.patternPrevFunctionInMeasure(call.toString()));
			}
			if (firstLastCount != 0) {
				throw newValidationError(call,
					Static.RESOURCE.patternPrevFunctionOrder(call.toString()));
			}
			prevNextCount++;
		} else if (isLogicalNavigation(kind)) {
			if (firstLastCount != 0) {
				throw newValidationError(call,
					Static.RESOURCE.patternPrevFunctionOrder(call.toString()));
			}
			firstLastCount++;
		} else if (isAggregation(kind)) {
			// cannot apply aggregation in PREV/NEXT, FIRST/LAST
			if (firstLastCount != 0 || prevNextCount != 0) {
				throw newValidationError(call,
					Static.RESOURCE.patternAggregationInNavigation(call.toString()));
			}
			if (kind == SqlKind.COUNT && call.getOperandList().size() > 1) {
				throw newValidationError(call,
					Static.RESOURCE.patternCountFunctionArg());
			}
			aggregateCount++;
		}
	}

	if (isRunningOrFinal(kind) && !isMeasure) {
		throw newValidationError(call,
			Static.RESOURCE.patternRunningFunctionInDefine(call.toString()));
	}

	for (SqlNode node : operands) {
		if (node != null) {
			vars.addAll(
				node.accept(
					new PatternValidator(isMeasure, firstLastCount, prevNextCount,
						aggregateCount)));
		}
	}

	if (isSingle) {
		switch (kind) {
			case COUNT:
				if (vars.size() > 1) {
					throw newValidationError(call,
						Static.RESOURCE.patternCountFunctionArg());
				}
				break;
			default:
				if (operands.size() == 0
					|| !(operands.get(0) instanceof SqlCall)
					|| ((SqlCall) operands.get(0)).getOperator() != SqlStdOperatorTable.CLASSIFIER) {
					if (vars.isEmpty()) {
						throw newValidationError(call,
							Static.RESOURCE.patternFunctionNullCheck(call.toString()));
					}
					if (vars.size() != 1) {
						throw newValidationError(call,
							Static.RESOURCE.patternFunctionVariableCheck(call.toString()));
					}
				}
				break;
		}
	}
	return vars;
}
 
Example 17
Source File: Util.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Override public Void visit(SqlCall call) {
  if (call.getKind() == SqlKind.OVER) {
    throw FoundOne.NULL;
  }
  return super.visit(call);
}
 
Example 18
Source File: SqlValidatorImpl.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override public SqlNode visit(SqlCall call) {
	SqlKind kind = call.getKind();
	List<SqlNode> operands = call.getOperandList();
	List<SqlNode> newOperands = new ArrayList<>();

	// This code is a workaround for CALCITE-2707
	if (call.getFunctionQuantifier() != null
		&& call.getFunctionQuantifier().getValue() == SqlSelectKeyword.DISTINCT) {
		final SqlParserPos pos = call.getParserPosition();
		throw SqlUtil.newContextException(pos, Static.RESOURCE.functionQuantifierNotAllowed(call.toString()));
	}
	// This code is a workaround for CALCITE-2707

	if (isLogicalNavigation(kind) || isPhysicalNavigation(kind)) {
		SqlNode inner = operands.get(0);
		SqlNode offset = operands.get(1);

		// merge two straight prev/next, update offset
		if (isPhysicalNavigation(kind)) {
			SqlKind innerKind = inner.getKind();
			if (isPhysicalNavigation(innerKind)) {
				List<SqlNode> innerOperands = ((SqlCall) inner).getOperandList();
				SqlNode innerOffset = innerOperands.get(1);
				SqlOperator newOperator = innerKind == kind
					? SqlStdOperatorTable.PLUS : SqlStdOperatorTable.MINUS;
				offset = newOperator.createCall(SqlParserPos.ZERO,
					offset, innerOffset);
				inner = call.getOperator().createCall(SqlParserPos.ZERO,
					innerOperands.get(0), offset);
			}
		}
		SqlNode newInnerNode =
			inner.accept(new NavigationExpander(call.getOperator(), offset));
		if (op != null) {
			newInnerNode = op.createCall(SqlParserPos.ZERO, newInnerNode,
				this.offset);
		}
		return newInnerNode;
	}

	if (operands.size() > 0) {
		for (SqlNode node : operands) {
			if (node != null) {
				SqlNode newNode = node.accept(new NavigationExpander());
				if (op != null) {
					newNode = op.createCall(SqlParserPos.ZERO, newNode, offset);
				}
				newOperands.add(newNode);
			} else {
				newOperands.add(null);
			}
		}
		return call.getOperator().createCall(SqlParserPos.ZERO, newOperands);
	} else {
		if (op == null) {
			return call;
		} else {
			return op.createCall(SqlParserPos.ZERO, call, offset);
		}
	}
}
 
Example 19
Source File: MockCatalogReader.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Override public boolean rolledUpColumnValidInsideAgg(String column,
    SqlCall call, SqlNode parent, CalciteConnectionConfig config) {
  // For testing
  return call.getKind() != SqlKind.MAX
      && (parent.getKind() == SqlKind.SELECT || parent.getKind() == SqlKind.FILTER);
}
 
Example 20
Source File: SqlValidatorImpl.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override public Set<String> visit(SqlCall call) {
	boolean isSingle = false;
	Set<String> vars = new HashSet<>();
	SqlKind kind = call.getKind();
	List<SqlNode> operands = call.getOperandList();

	if (isSingleVarRequired(kind)) {
		isSingle = true;
		if (isPhysicalNavigation(kind)) {
			if (isMeasure) {
				throw newValidationError(call,
					Static.RESOURCE.patternPrevFunctionInMeasure(call.toString()));
			}
			if (firstLastCount != 0) {
				throw newValidationError(call,
					Static.RESOURCE.patternPrevFunctionOrder(call.toString()));
			}
			prevNextCount++;
		} else if (isLogicalNavigation(kind)) {
			if (firstLastCount != 0) {
				throw newValidationError(call,
					Static.RESOURCE.patternPrevFunctionOrder(call.toString()));
			}
			firstLastCount++;
		} else if (isAggregation(kind)) {
			// cannot apply aggregation in PREV/NEXT, FIRST/LAST
			if (firstLastCount != 0 || prevNextCount != 0) {
				throw newValidationError(call,
					Static.RESOURCE.patternAggregationInNavigation(call.toString()));
			}
			if (kind == SqlKind.COUNT && call.getOperandList().size() > 1) {
				throw newValidationError(call,
					Static.RESOURCE.patternCountFunctionArg());
			}
			aggregateCount++;
		}
	}

	if (isRunningOrFinal(kind) && !isMeasure) {
		throw newValidationError(call,
			Static.RESOURCE.patternRunningFunctionInDefine(call.toString()));
	}

	for (SqlNode node : operands) {
		if (node != null) {
			vars.addAll(
				node.accept(
					new PatternValidator(isMeasure, firstLastCount, prevNextCount,
						aggregateCount)));
		}
	}

	if (isSingle) {
		switch (kind) {
			case COUNT:
				if (vars.size() > 1) {
					throw newValidationError(call,
						Static.RESOURCE.patternCountFunctionArg());
				}
				break;
			default:
				if (operands.size() == 0
					|| !(operands.get(0) instanceof SqlCall)
					|| ((SqlCall) operands.get(0)).getOperator() != SqlStdOperatorTable.CLASSIFIER) {
					if (vars.isEmpty()) {
						throw newValidationError(call,
							Static.RESOURCE.patternFunctionNullCheck(call.toString()));
					}
					if (vars.size() != 1) {
						throw newValidationError(call,
							Static.RESOURCE.patternFunctionVariableCheck(call.toString()));
					}
				}
				break;
		}
	}
	return vars;
}