OmniSciDB  c1a53651b2
 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 6400 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 6407 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.

6407  {
6408  SqlKind kind = call.getKind();
6409  if (isLogicalNavigation(kind)
6410  || isAggregation(kind)
6411  || isRunningOrFinal(kind)) {
6412  return call;
6413  }
6414 
6415  switch (kind) {
6416  case PREV:
6417  final List<SqlNode> operands = call.getOperandList();
6418  if (operands.get(0) instanceof SqlIdentifier) {
6419  String name = ((SqlIdentifier) operands.get(0)).names.get(0);
6420  return name.equals(alpha) ? call
6421  : SqlStdOperatorTable.LAST.createCall(SqlParserPos.ZERO, operands);
6422  }
6423  }
6424  return super.visit(call);
6425  }
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 6427 of file SqlValidatorImpl.java.

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

6427  {
6428  if (id.isSimple()) {
6429  return id;
6430  }
6431  SqlOperator operator = id.names.get(0).equals(alpha)
6432  ? SqlStdOperatorTable.PREV : SqlStdOperatorTable.LAST;
6433 
6434  return operator.createCall(SqlParserPos.ZERO, id,
6435  SqlLiteral.createExactNumeric("0", SqlParserPos.ZERO));
6436  }

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: