OmniSciDB  c1a53651b2
 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 6305 of file SqlValidatorImpl.java.

Constructor & Destructor Documentation

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

Definition at line 6309 of file SqlValidatorImpl.java.

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

6309  {
6310  this(null, null);
6311  }

+ Here is the caller graph for this function:

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

Definition at line 6313 of file SqlValidatorImpl.java.

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

6313  {
6314  this.offset = offset;
6315  this.op = operator;
6316  }

Member Function Documentation

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

Definition at line 6318 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.

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

+ Here is the call graph for this function:

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

Definition at line 6379 of file SqlValidatorImpl.java.

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

6379  {
6380  if (op == null) {
6381  return id;
6382  } else {
6383  return op.createCall(SqlParserPos.ZERO, id, offset);
6384  }
6385  }

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: