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

Public Member Functions

SqlNode visit (SqlCall call)
 
SqlNode visit (SqlIdentifier id)
 
- Public Member Functions inherited from org.apache.calcite.sql.validate.SqlValidatorImpl.NavigationModifier
SqlNode go (SqlNode node)
 

Package Functions

 NavigationExpander ()
 
 NavigationExpander (SqlOperator operator, SqlNode offset)
 

Package Attributes

final SqlOperator op
 
final SqlNode offset
 

Detailed Description

Shuttle that expands navigation expressions in a MATCH_RECOGNIZE clause.

Examples:

  • PREV(A.price + A.amount)

    PREV(A.price) + PREV(A.amount)

  • FIRST(A.price * 2)
    FIRST(A.PRICE) * 2

Definition at line 6316 of file SqlValidatorImpl.java.

Constructor & Destructor Documentation

org.apache.calcite.sql.validate.SqlValidatorImpl.NavigationExpander.NavigationExpander ( )
inlinepackage

Definition at line 6320 of file SqlValidatorImpl.java.

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

6320  {
6321  this(null, null);
6322  }

+ Here is the caller graph for this function:

org.apache.calcite.sql.validate.SqlValidatorImpl.NavigationExpander.NavigationExpander ( SqlOperator  operator,
SqlNode  offset 
)
inlinepackage

Definition at line 6324 of file SqlValidatorImpl.java.

References org.apache.calcite.sql.validate.SqlValidatorImpl.NavigationExpander.offset.

6324  {
6325  this.offset = offset;
6326  this.op = operator;
6327  }

Member Function Documentation

SqlNode org.apache.calcite.sql.validate.SqlValidatorImpl.NavigationExpander.visit ( SqlCall  call)
inline

Definition at line 6329 of file SqlValidatorImpl.java.

References org.apache.calcite.sql.validate.SqlValidatorImpl.isLogicalNavigation(), org.apache.calcite.sql.validate.SqlValidatorImpl.isPhysicalNavigation(), org.apache.calcite.sql.validate.SqlValidatorImpl.NavigationExpander.NavigationExpander(), org.apache.calcite.sql.validate.SqlValidatorImpl.NavigationExpander.offset, and org.apache.calcite.sql.validate.SqlValidatorImpl.NavigationExpander.op.

6329  {
6330  SqlKind kind = call.getKind();
6331  List<SqlNode> operands = call.getOperandList();
6332  List<SqlNode> newOperands = new ArrayList<>();
6333 
6334  if (call.getFunctionQuantifier() != null
6335  && call.getFunctionQuantifier().getValue() == SqlSelectKeyword.DISTINCT) {
6336  final SqlParserPos pos = call.getParserPosition();
6337  throw SqlUtil.newContextException(pos,
6338  Static.RESOURCE.functionQuantifierNotAllowed(call.toString()));
6339  }
6340 
6341  if (isLogicalNavigation(kind) || isPhysicalNavigation(kind)) {
6342  SqlNode inner = operands.get(0);
6343  SqlNode offset = operands.get(1);
6344 
6345  // merge two straight prev/next, update offset
6346  if (isPhysicalNavigation(kind)) {
6347  SqlKind innerKind = inner.getKind();
6348  if (isPhysicalNavigation(innerKind)) {
6349  List<SqlNode> innerOperands = ((SqlCall) inner).getOperandList();
6350  SqlNode innerOffset = innerOperands.get(1);
6351  SqlOperator newOperator = innerKind == kind
6352  ? SqlStdOperatorTable.PLUS : SqlStdOperatorTable.MINUS;
6353  offset = newOperator.createCall(SqlParserPos.ZERO,
6354  offset, innerOffset);
6355  inner = call.getOperator().createCall(SqlParserPos.ZERO,
6356  innerOperands.get(0), offset);
6357  }
6358  }
6359  SqlNode newInnerNode =
6360  inner.accept(new NavigationExpander(call.getOperator(), offset));
6361  if (op != null) {
6362  newInnerNode = op.createCall(SqlParserPos.ZERO, newInnerNode,
6363  this.offset);
6364  }
6365  return newInnerNode;
6366  }
6367 
6368  if (operands.size() > 0) {
6369  for (SqlNode node : operands) {
6370  if (node != null) {
6371  SqlNode newNode = node.accept(new NavigationExpander());
6372  if (op != null) {
6373  newNode = op.createCall(SqlParserPos.ZERO, newNode, offset);
6374  }
6375  newOperands.add(newNode);
6376  } else {
6377  newOperands.add(null);
6378  }
6379  }
6380  return call.getOperator().createCall(SqlParserPos.ZERO, newOperands);
6381  } else {
6382  if (op == null) {
6383  return call;
6384  } else {
6385  return op.createCall(SqlParserPos.ZERO, call, offset);
6386  }
6387  }
6388  }

+ Here is the call graph for this function:

SqlNode org.apache.calcite.sql.validate.SqlValidatorImpl.NavigationExpander.visit ( SqlIdentifier  id)
inline

Definition at line 6390 of file SqlValidatorImpl.java.

References org.apache.calcite.sql.validate.SqlValidatorImpl.NavigationExpander.offset, and org.apache.calcite.sql.validate.SqlValidatorImpl.NavigationExpander.op.

6390  {
6391  if (op == null) {
6392  return id;
6393  } else {
6394  return op.createCall(SqlParserPos.ZERO, id, offset);
6395  }
6396  }

Member Data Documentation

final SqlNode org.apache.calcite.sql.validate.SqlValidatorImpl.NavigationExpander.offset
package
final SqlOperator org.apache.calcite.sql.validate.SqlValidatorImpl.NavigationExpander.op
package

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