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

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

 NavigationReplacer (String alpha)
 

Private Attributes

final String alpha
 

Detailed Description

Shuttle that replaces

A as A.price > PREV(B.price)

with

PREV(A.price, 0) > LAST(B.price, 0)

.

Replacing

A.price

with

PREV(A.price, 0)

makes the implementation of RexVisitor#visitPatternFieldRef(RexPatternFieldRef) more unified. Otherwise, it's difficult to implement this method. If it returns the specified field, then the navigation such as

PREV(A.price, 1)

becomes impossible; if not, then comparisons such as

A.price > PREV(A.price, 1)

become meaningless.

Definition at line 6411 of file SqlValidatorImpl.java.

Constructor & Destructor Documentation

org.apache.calcite.sql.validate.SqlValidatorImpl.NavigationReplacer.NavigationReplacer ( String  alpha)
inlinepackage

Member Function Documentation

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

Definition at line 6418 of file SqlValidatorImpl.java.

References org.apache.calcite.sql.validate.SqlValidatorImpl.NavigationReplacer.alpha, org.apache.calcite.sql.validate.SqlValidatorImpl.isAggregation(), org.apache.calcite.sql.validate.SqlValidatorImpl.isLogicalNavigation(), org.apache.calcite.sql.validate.SqlValidatorImpl.isRunningOrFinal(), and setup.name.

6418  {
6419  SqlKind kind = call.getKind();
6420  if (isLogicalNavigation(kind)
6421  || isAggregation(kind)
6422  || isRunningOrFinal(kind)) {
6423  return call;
6424  }
6425 
6426  switch (kind) {
6427  case PREV:
6428  final List<SqlNode> operands = call.getOperandList();
6429  if (operands.get(0) instanceof SqlIdentifier) {
6430  String name = ((SqlIdentifier) operands.get(0)).names.get(0);
6431  return name.equals(alpha) ? call
6432  : SqlStdOperatorTable.LAST.createCall(SqlParserPos.ZERO, operands);
6433  }
6434  }
6435  return super.visit(call);
6436  }
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

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

Definition at line 6438 of file SqlValidatorImpl.java.

References org.apache.calcite.sql.validate.SqlValidatorImpl.NavigationReplacer.alpha.

6438  {
6439  if (id.isSimple()) {
6440  return id;
6441  }
6442  SqlOperator operator = id.names.get(0).equals(alpha)
6443  ? SqlStdOperatorTable.PREV : SqlStdOperatorTable.LAST;
6444 
6445  return operator.createCall(SqlParserPos.ZERO, id,
6446  SqlLiteral.createExactNumeric("0", SqlParserPos.ZERO));
6447  }

Member Data Documentation

final String org.apache.calcite.sql.validate.SqlValidatorImpl.NavigationReplacer.alpha
private

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