OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator Class Reference
+ Inheritance diagram for org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator:
+ Collaboration diagram for org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator:

Public Member Functions

Set< String > visit (SqlCall call)
 
Set< String > visit (SqlIdentifier identifier)
 
Set< String > visit (SqlLiteral literal)
 
Set< String > visit (SqlIntervalQualifier qualifier)
 
Set< String > visit (SqlDataTypeSpec type)
 
Set< String > visit (SqlDynamicParam param)
 

Package Functions

 PatternValidator (boolean isMeasure)
 
 PatternValidator (boolean isMeasure, int firstLastCount, int prevNextCount, int aggregateCount)
 

Package Attributes

int firstLastCount
 
int prevNextCount
 
int aggregateCount
 

Private Attributes

final boolean isMeasure
 

Detailed Description

Validates that within one navigation function, the pattern var is the same.

Definition at line 6441 of file SqlValidatorImpl.java.

Constructor & Destructor Documentation

org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.PatternValidator ( boolean  isMeasure)
inlinepackage

Definition at line 6447 of file SqlValidatorImpl.java.

References org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.isMeasure.

Referenced by org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.visit().

6447  {
6448  this(isMeasure, 0, 0, 0);
6449  }

+ Here is the caller graph for this function:

Member Function Documentation

Set<String> org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.visit ( SqlCall  call)
inline

Definition at line 6459 of file SqlValidatorImpl.java.

References org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.aggregateCount, COUNT, org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.firstLastCount, org.apache.calcite.sql.validate.SqlValidatorImpl.isAggregation(), org.apache.calcite.sql.validate.SqlValidatorImpl.isLogicalNavigation(), org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.isMeasure, org.apache.calcite.sql.validate.SqlValidatorImpl.isPhysicalNavigation(), org.apache.calcite.sql.validate.SqlValidatorImpl.isRunningOrFinal(), org.apache.calcite.sql.validate.SqlValidatorImpl.isSingleVarRequired(), org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(), org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.PatternValidator(), and org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.prevNextCount.

6459  {
6460  boolean isSingle = false;
6461  Set<String> vars = new HashSet<>();
6462  SqlKind kind = call.getKind();
6463  List<SqlNode> operands = call.getOperandList();
6464 
6465  if (isSingleVarRequired(kind)) {
6466  isSingle = true;
6467  if (isPhysicalNavigation(kind)) {
6468  if (isMeasure) {
6469  throw newValidationError(call,
6470  Static.RESOURCE.patternPrevFunctionInMeasure(call.toString()));
6471  }
6472  if (firstLastCount != 0) {
6473  throw newValidationError(call,
6474  Static.RESOURCE.patternPrevFunctionOrder(call.toString()));
6475  }
6476  prevNextCount++;
6477  } else if (isLogicalNavigation(kind)) {
6478  if (firstLastCount != 0) {
6479  throw newValidationError(call,
6480  Static.RESOURCE.patternPrevFunctionOrder(call.toString()));
6481  }
6482  firstLastCount++;
6483  } else if (isAggregation(kind)) {
6484  // cannot apply aggregation in PREV/NEXT, FIRST/LAST
6485  if (firstLastCount != 0 || prevNextCount != 0) {
6486  throw newValidationError(call,
6487  Static.RESOURCE.patternAggregationInNavigation(call.toString()));
6488  }
6489  if (kind == SqlKind.COUNT && call.getOperandList().size() > 1) {
6490  throw newValidationError(call,
6491  Static.RESOURCE.patternCountFunctionArg());
6492  }
6493  aggregateCount++;
6494  }
6495  }
6496 
6497  if (isRunningOrFinal(kind) && !isMeasure) {
6498  throw newValidationError(call,
6499  Static.RESOURCE.patternRunningFunctionInDefine(call.toString()));
6500  }
6501 
6502  for (SqlNode node : operands) {
6503  if (node != null) {
6504  vars.addAll(
6505  node.accept(
6507  aggregateCount)));
6508  }
6509  }
6510 
6511  if (isSingle) {
6512  switch (kind) {
6513  case COUNT:
6514  if (vars.size() > 1) {
6515  throw newValidationError(call,
6516  Static.RESOURCE.patternCountFunctionArg());
6517  }
6518  break;
6519  default:
6520  if (operands.size() == 0
6521  || !(operands.get(0) instanceof SqlCall)
6522  || ((SqlCall) operands.get(0)).getOperator() != SqlStdOperatorTable.CLASSIFIER) {
6523  if (vars.isEmpty()) {
6524  throw newValidationError(call,
6525  Static.RESOURCE.patternFunctionNullCheck(call.toString()));
6526  }
6527  if (vars.size() != 1) {
6528  throw newValidationError(call,
6529  Static.RESOURCE.patternFunctionVariableCheck(call.toString()));
6530  }
6531  }
6532  break;
6533  }
6534  }
6535  return vars;
6536  }
CalciteContextException newValidationError(SqlNode node, Resources.ExInst< SqlValidatorException > e)

+ Here is the call graph for this function:

Set<String> org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.visit ( SqlIdentifier  identifier)
inline
Set<String> org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.visit ( SqlLiteral  literal)
inline

Definition at line 6547 of file SqlValidatorImpl.java.

6547  {
6548  return ImmutableSet.of();
6549  }
Set<String> org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.visit ( SqlIntervalQualifier  qualifier)
inline

Definition at line 6551 of file SqlValidatorImpl.java.

6551  {
6552  return ImmutableSet.of();
6553  }
Set<String> org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.visit ( SqlDataTypeSpec  type)
inline

Definition at line 6555 of file SqlValidatorImpl.java.

6555  {
6556  return ImmutableSet.of();
6557  }
Set<String> org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.visit ( SqlDynamicParam  param)
inline

Definition at line 6559 of file SqlValidatorImpl.java.

6559  {
6560  return ImmutableSet.of();
6561  }

Member Data Documentation

int org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.aggregateCount
package
int org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.firstLastCount
package
final boolean org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.isMeasure
private
int org.apache.calcite.sql.validate.SqlValidatorImpl.PatternValidator.prevNextCount
package

The documentation for this class was generated from the following file: