OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
org.apache.calcite.sql.SqlOperator Class Referenceabstract
+ Collaboration diagram for org.apache.calcite.sql.SqlOperator:

Public Member Functions

SqlOperandTypeChecker getOperandTypeChecker ()
 
SqlOperandCountRange getOperandCountRange ()
 
boolean requiresCreate (List< SqlNode > operands)
 
String getName ()
 
SqlIdentifier getNameAsId ()
 
SqlKind getKind ()
 
String toString ()
 
int getLeftPrec ()
 
int getRightPrec ()
 
abstract SqlSyntax getSyntax ()
 
SqlCall createCall (SqlLiteral functionQualifier, SqlParserPos pos, SqlNode...operands)
 
final SqlCall createCall (SqlParserPos pos, SqlNode...operands)
 
final SqlCall createCall (SqlNodeList nodeList)
 
final SqlCall createCall (SqlParserPos pos, List<?extends SqlNode > operandList)
 
SqlNode rewriteCall (SqlValidator validator, SqlCall call)
 
void unparse (SqlWriter writer, SqlCall call, int leftPrec, int rightPrec)
 
boolean equals (Object obj)
 
boolean isName (String testName, boolean caseSensitive)
 
int hashCode ()
 
void validateCall (SqlCall call, SqlValidator validator, SqlValidatorScope scope, SqlValidatorScope operandScope)
 
final RelDataType validateOperands (SqlValidator validator, SqlValidatorScope scope, SqlCall call)
 
RelDataType inferReturnType (SqlOperatorBinding opBinding)
 
RelDataType deriveType (SqlValidator validator, SqlValidatorScope scope, SqlCall call)
 
final RelDataType inferReturnType (RelDataTypeFactory typeFactory, List< RelDataType > operandTypes)
 
boolean checkOperandTypes (SqlCallBinding callBinding, boolean throwOnFailure)
 
boolean validRexOperands (int count, Litmus litmus)
 
String getSignatureTemplate (final int operandsCount)
 
final String getAllowedSignatures ()
 
String getAllowedSignatures (String opNameToUse)
 
SqlOperandTypeInference getOperandTypeInference ()
 
boolean isAggregator ()
 
boolean requiresOver ()
 
boolean requiresOrder ()
 
boolean allowsFraming ()
 
boolean isGroup ()
 
boolean isGroupAuxiliary ()
 
SqlReturnTypeInference getReturnTypeInference ()
 
Supplier< Strong.Policy > getStrongPolicyInference ()
 
SqlMonotonicity getMonotonicity (SqlCall call, SqlValidatorScope scope)
 
SqlMonotonicity getMonotonicity (SqlOperatorBinding call)
 
boolean isDeterministic ()
 
boolean isSymmetrical ()
 
boolean isDynamicFunction ()
 
boolean requiresDecimalExpansion ()
 
boolean argumentMustBeScalar (int ordinal)
 

Public Attributes

final SqlKind kind
 

Static Public Attributes

static final String NL = System.getProperty("line.separator")
 
static final int MDX_PRECEDENCE = 200
 

Protected Member Functions

 SqlOperator (String name, SqlKind kind, int leftPrecedence, int rightPrecedence, SqlReturnTypeInference returnTypeInference, SqlOperandTypeInference operandTypeInference, SqlOperandTypeChecker operandTypeChecker)
 
 SqlOperator (String name, SqlKind kind, int prec, boolean leftAssoc, SqlReturnTypeInference returnTypeInference, SqlOperandTypeInference operandTypeInference, SqlOperandTypeChecker operandTypeChecker)
 
void unparseListClause (SqlWriter writer, SqlNode clause)
 
void unparseListClause (SqlWriter writer, SqlNode clause, SqlKind sepKind)
 
void preValidateCall (SqlValidator validator, SqlValidatorScope scope, SqlCall call)
 
List< String > constructArgNameList (SqlCall call)
 
List< SqlNode > constructOperandList (SqlValidator validator, SqlCall call, List< String > argNames)
 
List< RelDataType > constructArgTypeList (SqlValidator validator, SqlValidatorScope scope, SqlCall call, List< SqlNode > args, boolean convertRowArgToColumnList)
 
RelDataType adjustType (SqlValidator validator, final SqlCall call, RelDataType type)
 
void checkOperandCount (SqlValidator validator, SqlOperandTypeChecker argType, SqlCall call)
 

Static Protected Member Functions

static int leftPrec (int prec, boolean leftAssoc)
 
static int rightPrec (int prec, boolean leftAssoc)
 

Package Functions

boolean needsSpace ()
 
public< R > R acceptCall (SqlVisitor< R > visitor, SqlCall call)
 
public< R > void acceptCall (SqlVisitor< R > visitor, SqlCall call, boolean onlyExpressions, SqlBasicVisitor.ArgHandler< R > argHandler)
 

Private Attributes

final String name
 
final int leftPrec
 
final int rightPrec
 
final SqlReturnTypeInference returnTypeInference
 
final SqlOperandTypeInference operandTypeInference
 
final SqlOperandTypeChecker operandTypeChecker
 

Detailed Description

A SqlOperator is a type of node in a SQL parse tree (it is NOT a node in a SQL parse tree). It includes functions, operators such as '=', and syntactic constructs such as 'case' statements. Operators may represent query-level expressions (e.g. SqlSelectOperator or row-level expressions (e.g. org.apache.calcite.sql.fun.SqlBetweenOperator.

Operators have formal operands, meaning ordered (and optionally named) placeholders for the values they operate on. For example, the division operator takes two operands; the first is the numerator and the second is the denominator. In the context of subclass SqlFunction, formal operands are referred to as parameters.

When an operator is instantiated via a SqlCall, it is supplied with actual operands. For example, in the expression 3 / 5, the literal expression 3 is the actual operand corresponding to the numerator, and 5 is the actual operand corresponding to the denominator. In the context of SqlFunction, actual operands are referred to as arguments

In many cases, the formal/actual distinction is clear from context, in which case we drop these qualifiers.

Definition at line 74 of file SqlOperator.java.

Constructor & Destructor Documentation

org.apache.calcite.sql.SqlOperator.SqlOperator ( String  name,
SqlKind  kind,
int  leftPrecedence,
int  rightPrecedence,
SqlReturnTypeInference  returnTypeInference,
SqlOperandTypeInference  operandTypeInference,
SqlOperandTypeChecker  operandTypeChecker 
)
inlineprotected

Creates an operator.

Definition at line 125 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.kind, org.apache.calcite.sql.SqlOperator.name, org.apache.calcite.sql.SqlOperator.operandTypeChecker, org.apache.calcite.sql.SqlOperator.operandTypeInference, and org.apache.calcite.sql.SqlOperator.returnTypeInference.

Referenced by org.apache.calcite.sql.SqlOperator.equals().

132  {
133  assert kind != null;
134  this.name = name;
135  this.kind = kind;
136  this.leftPrec = leftPrecedence;
137  this.rightPrec = rightPrecedence;
138  this.returnTypeInference = returnTypeInference;
139  this.operandTypeInference = operandTypeInference;
140  this.operandTypeChecker = operandTypeChecker;
141  }
final SqlOperandTypeChecker operandTypeChecker
final SqlReturnTypeInference returnTypeInference
final SqlOperandTypeInference operandTypeInference

+ Here is the caller graph for this function:

org.apache.calcite.sql.SqlOperator.SqlOperator ( String  name,
SqlKind  kind,
int  prec,
boolean  leftAssoc,
SqlReturnTypeInference  returnTypeInference,
SqlOperandTypeInference  operandTypeInference,
SqlOperandTypeChecker  operandTypeChecker 
)
inlineprotected

Member Function Documentation

public<R> R org.apache.calcite.sql.SqlOperator.acceptCall ( SqlVisitor< R >  visitor,
SqlCall  call 
)
inlinepackage

Accepts a SqlVisitor, visiting each operand of a call. Returns null.

Parameters
visitorVisitor
callCall to visit

Definition at line 857 of file SqlOperator.java.

857  {
858  for (SqlNode operand : call.getOperandList()) {
859  if (operand == null) {
860  continue;
861  }
862  operand.accept(visitor);
863  }
864  return null;
865  }
public<R> void org.apache.calcite.sql.SqlOperator.acceptCall ( SqlVisitor< R >  visitor,
SqlCall  call,
boolean  onlyExpressions,
SqlBasicVisitor.ArgHandler< R >  argHandler 
)
inlinepackage

Accepts a SqlVisitor, directing an org.apache.calcite.sql.util.SqlBasicVisitor.ArgHandler to visit an operand of a call.

The argument handler allows fine control about how the operands are visited, and how the results are combined.

Parameters
visitorVisitor
callCall to visit
onlyExpressionsIf true, ignores operands which are not expressions. For example, in the call to the AS operator
argHandlerCalled for each operand

Definition at line 882 of file SqlOperator.java.

886  {
887  List<SqlNode> operands = call.getOperandList();
888  for (int i = 0; i < operands.size(); i++) {
889  argHandler.visitChild(visitor, call, i, operands.get(i));
890  }
891  }
RelDataType org.apache.calcite.sql.SqlOperator.adjustType ( SqlValidator  validator,
final SqlCall  call,
RelDataType  type 
)
inlineprotected

Validates and determines coercibility and resulting collation name of binary operator if needed.

Definition at line 638 of file SqlOperator.java.

References run_benchmark_import.type.

Referenced by org.apache.calcite.sql.SqlOperator.deriveType().

641  {
642  return type;
643  }

+ Here is the caller graph for this function:

boolean org.apache.calcite.sql.SqlOperator.allowsFraming ( )
inline

Returns whether this is a window function that allows framing (i.e. a ROWS or RANGE clause in the window specification).

Definition at line 820 of file SqlOperator.java.

820  {
821  return true;
822  }
boolean org.apache.calcite.sql.SqlOperator.argumentMustBeScalar ( int  ordinal)
inline

Returns whether the ordinalth argument to this operator must be scalar (as opposed to a query).

If true (the default), the validator will attempt to convert the argument into a scalar sub-query, which must have one column and return at most one row.

Operators such as SELECT and EXISTS override this method.

Definition at line 986 of file SqlOperator.java.

986  {
987  return true;
988  }
void org.apache.calcite.sql.SqlOperator.checkOperandCount ( SqlValidator  validator,
SqlOperandTypeChecker  argType,
SqlCall  call 
)
inlineprotected

Definition at line 694 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.getName(), and org.apache.calcite.sql.SqlOperator.getOperandCountRange().

Referenced by org.apache.calcite.sql.SqlOperator.validateOperands().

697  {
698  SqlOperandCountRange od = call.getOperator().getOperandCountRange();
699  if (od.isValidCount(call.operandCount())) {
700  return;
701  }
702  if (od.getMin() == od.getMax()) {
703  throw validator.newValidationError(call,
704  RESOURCE.invalidArgCount(call.getOperator().getName(), od.getMin()));
705  } else {
706  throw validator.newValidationError(call, RESOURCE.wrongNumOfArguments());
707  }
708  }
SqlOperandCountRange getOperandCountRange()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

boolean org.apache.calcite.sql.SqlOperator.checkOperandTypes ( SqlCallBinding  callBinding,
boolean  throwOnFailure 
)
inline

Checks that the operand values in a SqlCall to this operator are valid. Subclasses must either override this method or supply an instance of SqlOperandTypeChecker to the constructor.

Parameters
callBindingdescription of call
throwOnFailurewhether to throw an exception if check fails (otherwise returns false in that case)
Returns
whether check succeeded

Definition at line 669 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.kind, and org.apache.calcite.sql.SqlOperator.operandTypeChecker.

Referenced by org.apache.calcite.sql.SqlOperator.validateOperands().

671  {
672  // Check that all of the operands are of the right type.
673  if (null == operandTypeChecker) {
674  // If you see this you must either give operandTypeChecker a value
675  // or override this method.
676  throw Util.needToImplement(this);
677  }
678 
679  if (kind != SqlKind.ARGUMENT_ASSIGNMENT) {
680  for (Ord<SqlNode> operand : Ord.zip(callBinding.operands())) {
681  if (operand.e != null
682  && operand.e.getKind() == SqlKind.DEFAULT
683  && !operandTypeChecker.isOptional(operand.i)) {
684  throw callBinding.newValidationError(RESOURCE.defaultForOptionalParameter());
685  }
686  }
687  }
688 
689  return operandTypeChecker.checkOperandTypes(
690  callBinding,
691  throwOnFailure);
692  }
final SqlOperandTypeChecker operandTypeChecker

+ Here is the caller graph for this function:

List<String> org.apache.calcite.sql.SqlOperator.constructArgNameList ( SqlCall  call)
inlineprotected

Definition at line 550 of file SqlOperator.java.

550  {
551  // If any arguments are named, construct a map.
552  final ImmutableList.Builder<String> nameBuilder = ImmutableList.builder();
553  for (SqlNode operand : call.getOperandList()) {
554  if (operand.getKind() == SqlKind.ARGUMENT_ASSIGNMENT) {
555  final List<SqlNode> operandList = ((SqlCall) operand).getOperandList();
556  nameBuilder.add(((SqlIdentifier) operandList.get(1)).getSimple());
557  }
558  }
559  ImmutableList<String> argNames = nameBuilder.build();
560 
561  if (argNames.isEmpty()) {
562  return null;
563  } else {
564  return argNames;
565  }
566  }
List<RelDataType> org.apache.calcite.sql.SqlOperator.constructArgTypeList ( SqlValidator  validator,
SqlValidatorScope  scope,
SqlCall  call,
List< SqlNode >  args,
boolean  convertRowArgToColumnList 
)
inlineprotected

Definition at line 594 of file SqlOperator.java.

Referenced by org.apache.calcite.sql.SqlOperator.deriveType().

599  {
600  // Scope for operands. Usually the same as 'scope'.
601  final SqlValidatorScope operandScope = scope.getOperandScope(call);
602 
603  final ImmutableList.Builder<RelDataType> argTypeBuilder =
604  ImmutableList.builder();
605  for (SqlNode operand : args) {
606  RelDataType nodeType;
607  // for row arguments that should be converted to ColumnList
608  // types, set the nodeType to a ColumnList type but defer
609  // validating the arguments of the row constructor until we know
610  // for sure that the row argument maps to a ColumnList type
611  if (operand.getKind() == SqlKind.ROW && convertRowArgToColumnList) {
612  RelDataTypeFactory typeFactory = validator.getTypeFactory();
613  nodeType = typeFactory.createSqlType(SqlTypeName.COLUMN_LIST);
614  ((SqlValidatorImpl) validator).setValidatedNodeType(operand, nodeType);
615  } else {
616  nodeType = validator.deriveType(operandScope, operand);
617  }
618  argTypeBuilder.add(nodeType);
619  }
620 
621  return argTypeBuilder.build();
622  }

+ Here is the caller graph for this function:

List<SqlNode> org.apache.calcite.sql.SqlOperator.constructOperandList ( SqlValidator  validator,
SqlCall  call,
List< String >  argNames 
)
inlineprotected

Definition at line 568 of file SqlOperator.java.

Referenced by org.apache.calcite.sql.SqlOperator.deriveType().

571  {
572  if (argNames == null) {
573  return call.getOperandList();
574  }
575  if (argNames.size() < call.getOperandList().size()) {
576  throw validator.newValidationError(call,
577  RESOURCE.someButNotAllArgumentsAreNamed());
578  }
579  final int duplicate = Util.firstDuplicate(argNames);
580  if (duplicate >= 0) {
581  throw validator.newValidationError(call,
582  RESOURCE.duplicateArgumentName(argNames.get(duplicate)));
583  }
584  final ImmutableList.Builder<SqlNode> argBuilder = ImmutableList.builder();
585  for (SqlNode operand : call.getOperandList()) {
586  if (operand.getKind() == SqlKind.ARGUMENT_ASSIGNMENT) {
587  final List<SqlNode> operandList = ((SqlCall) operand).getOperandList();
588  argBuilder.add(operandList.get(0));
589  }
590  }
591  return argBuilder.build();
592  }

+ Here is the caller graph for this function:

SqlCall org.apache.calcite.sql.SqlOperator.createCall ( SqlLiteral  functionQualifier,
SqlParserPos  pos,
SqlNode...  operands 
)
inline

Creates a call to this operand with an array of operands.

The position of the resulting call is the union of the pos and the positions of all of the operands.

Parameters
functionQualifierfunction qualifier (e.g. "DISTINCT"), may be
posparser position of the identifier of the call
operandsarray of operands

Definition at line 254 of file SqlOperator.java.

Referenced by org.apache.calcite.sql.SqlOperator.createCall().

257  {
258  pos = pos.plusAll(Arrays.asList(operands));
259  return new SqlBasicCall(this, operands, pos, false, functionQualifier);
260  }

+ Here is the caller graph for this function:

final SqlCall org.apache.calcite.sql.SqlOperator.createCall ( SqlParserPos  pos,
SqlNode...  operands 
)
inline

Creates a call to this operand with an array of operands.

The position of the resulting call is the union of the pos and the positions of all of the operands.

Parameters
posParser position
operandsList of arguments
Returns
call to this operator

Definition at line 272 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.createCall().

274  {
275  return createCall(null, pos, operands);
276  }
SqlCall createCall(SqlLiteral functionQualifier, SqlParserPos pos, SqlNode...operands)

+ Here is the call graph for this function:

final SqlCall org.apache.calcite.sql.SqlOperator.createCall ( SqlNodeList  nodeList)
inline

Creates a call to this operand with a list of operands contained in a SqlNodeList.

The position of the resulting call inferred from the SqlNodeList.

Parameters
nodeListList of arguments
Returns
call to this operator

Definition at line 287 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.createCall().

288  {
289  return createCall(
290  null,
291  nodeList.getParserPosition(),
292  nodeList.toArray());
293  }
SqlCall createCall(SqlLiteral functionQualifier, SqlParserPos pos, SqlNode...operands)

+ Here is the call graph for this function:

final SqlCall org.apache.calcite.sql.SqlOperator.createCall ( SqlParserPos  pos,
List<?extends SqlNode >  operandList 
)
inline

Creates a call to this operand with a list of operands.

The position of the resulting call is the union of the pos and the positions of all of the operands.

Definition at line 301 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.createCall().

303  {
304  return createCall(
305  null,
306  pos,
307  operandList.toArray(new SqlNode[0]));
308  }
SqlCall createCall(SqlLiteral functionQualifier, SqlParserPos pos, SqlNode...operands)

+ Here is the call graph for this function:

RelDataType org.apache.calcite.sql.SqlOperator.deriveType ( SqlValidator  validator,
SqlValidatorScope  scope,
SqlCall  call 
)
inline

Derives the type of a call to this operator.

This method is an intrinsic part of the validation process so, unlike inferReturnType, specific operators would not typically override this method.

Parameters
validatorValidator
scopeScope of validation
callCall to this operator
Returns
Type of call

Definition at line 519 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.adjustType(), run_benchmark_import.args, org.apache.calcite.sql.SqlOperator.constructArgTypeList(), org.apache.calcite.sql.SqlOperator.constructOperandList(), org.apache.calcite.sql.SqlOperator.getKind(), org.apache.calcite.sql.SqlOperator.getNameAsId(), org.apache.calcite.sql.SqlOperator.getSyntax(), run_benchmark_import.type, and org.apache.calcite.sql.SqlOperator.validateOperands().

522  {
523  for (SqlNode operand : call.getOperandList()) {
524  RelDataType nodeType = validator.deriveType(scope, operand);
525  assert nodeType != null;
526  }
527 
528  final List<SqlNode> args = constructOperandList(validator, call, null);
529 
530  final List<RelDataType> argTypes = constructArgTypeList(validator, scope,
531  call, args, false);
532 
533  // Always disable type coercion for builtin operator operands,
534  // they are handled by the TypeCoercion specifically.
535  final SqlOperator sqlOperator =
536  SqlUtil.lookupRoutine(validator.getOperatorTable(), getNameAsId(),
537  argTypes, null, null, getSyntax(), getKind(),
538  validator.getCatalogReader().nameMatcher(), false);
539 
540  ((SqlBasicCall) call).setOperator(sqlOperator);
541  RelDataType type = call.getOperator().validateOperands(validator, scope, call);
542 
543  // Validate and determine coercibility and resulting collation
544  // name of binary operator if needed.
545  type = adjustType(validator, call, type);
546  SqlValidatorUtil.checkCharsetAndCollateConsistentIfCharType(type);
547  return type;
548  }
RelDataType adjustType(SqlValidator validator, final SqlCall call, RelDataType type)
SqlOperator(String name, SqlKind kind, int leftPrecedence, int rightPrecedence, SqlReturnTypeInference returnTypeInference, SqlOperandTypeInference operandTypeInference, SqlOperandTypeChecker operandTypeChecker)
List< RelDataType > constructArgTypeList(SqlValidator validator, SqlValidatorScope scope, SqlCall call, List< SqlNode > args, boolean convertRowArgToColumnList)
abstract SqlSyntax getSyntax()
List< SqlNode > constructOperandList(SqlValidator validator, SqlCall call, List< String > argNames)
final RelDataType validateOperands(SqlValidator validator, SqlValidatorScope scope, SqlCall call)

+ Here is the call graph for this function:

boolean org.apache.calcite.sql.SqlOperator.equals ( Object  obj)
inline

Definition at line 380 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.kind, setup.name, and org.apache.calcite.sql.SqlOperator.SqlOperator().

380  {
381  if (!(obj instanceof SqlOperator)) {
382  return false;
383  }
384  if (!obj.getClass().equals(this.getClass())) {
385  return false;
386  }
387  SqlOperator other = (SqlOperator) obj;
388  return name.equals(other.name) && kind == other.kind;
389  }
SqlOperator(String name, SqlKind kind, int leftPrecedence, int rightPrecedence, SqlReturnTypeInference returnTypeInference, SqlOperandTypeInference operandTypeInference, SqlOperandTypeChecker operandTypeChecker)
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

final String org.apache.calcite.sql.SqlOperator.getAllowedSignatures ( )
inline

Returns a string describing the expected operand types of a call, e.g. "SUBSTR(VARCHAR, INTEGER, INTEGER)".

Definition at line 741 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.name.

741  {
742  return getAllowedSignatures(name);
743  }
String org.apache.calcite.sql.SqlOperator.getAllowedSignatures ( String  opNameToUse)
inline

Returns a string describing the expected operand types of a call, e.g. "SUBSTRING(VARCHAR, INTEGER, INTEGER)" where the name (SUBSTRING in this example) can be replaced by a specified name.

Definition at line 750 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.operandTypeChecker.

750  {
751  assert operandTypeChecker != null
752  : "If you see this, assign operandTypeChecker a value "
753  + "or override this function";
754  return operandTypeChecker.getAllowedSignatures(this, opNameToUse)
755  .trim();
756  }
final SqlOperandTypeChecker operandTypeChecker
SqlKind org.apache.calcite.sql.SqlOperator.getKind ( )
inline

Definition at line 223 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.kind.

Referenced by org.apache.calcite.sql.SqlOperator.deriveType().

223  {
224  return kind;
225  }

+ Here is the caller graph for this function:

int org.apache.calcite.sql.SqlOperator.getLeftPrec ( )
inline

Definition at line 231 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.leftPrec.

231  {
232  return leftPrec;
233  }
SqlMonotonicity org.apache.calcite.sql.SqlOperator.getMonotonicity ( SqlCall  call,
SqlValidatorScope  scope 
)
inline

Returns whether this operator is monotonic.

Default implementation returns SqlMonotonicity#NOT_MONOTONIC.

Parameters
callCall to this operator
scopeScope in which the call occurs
Deprecated:
Use getMonotonicity(SqlOperatorBinding)

Definition at line 921 of file SqlOperator.java.

923  {
924  return getMonotonicity(
925  new SqlCallBinding(scope.getValidator(), scope, call));
926  }
SqlMonotonicity getMonotonicity(SqlCall call, SqlValidatorScope scope)
SqlMonotonicity org.apache.calcite.sql.SqlOperator.getMonotonicity ( SqlOperatorBinding  call)
inline

Returns whether a call to this operator is monotonic.

Default implementation returns SqlMonotonicity#NOT_MONOTONIC.

Parameters
callCall to this operator with particular arguments and information about the monotonicity of the arguments

Definition at line 936 of file SqlOperator.java.

936  {
937  return SqlMonotonicity.NOT_MONOTONIC;
938  }
String org.apache.calcite.sql.SqlOperator.getName ( )
inline

Definition at line 212 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.name.

Referenced by org.apache.calcite.sql.SqlOperator.checkOperandCount(), org.apache.calcite.sql.SqlOperator.getNameAsId(), and org.apache.calcite.sql.validate.SqlValidatorImpl.validateNoAggs().

212  {
213  return name;
214  }

+ Here is the caller graph for this function:

SqlIdentifier org.apache.calcite.sql.SqlOperator.getNameAsId ( )
inline

Returns the fully-qualified name of this operator.

Definition at line 219 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.getName().

Referenced by org.apache.calcite.sql.SqlOperator.deriveType().

219  {
220  return new SqlIdentifier(getName(), SqlParserPos.ZERO);
221  }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SqlOperandCountRange org.apache.calcite.sql.SqlOperator.getOperandCountRange ( )
inline

Returns a constraint on the number of operands expected by this operator. Subclasses may override this method; when they don't, the range is derived from the SqlOperandTypeChecker associated with this operator.

Returns
acceptable range

Definition at line 194 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.operandTypeChecker.

Referenced by org.apache.calcite.sql.SqlOperator.checkOperandCount().

194  {
195  if (operandTypeChecker != null) {
196  return operandTypeChecker.getOperandCountRange();
197  }
198 
199  // If you see this error you need to override this method
200  // or give operandTypeChecker a value.
201  throw Util.needToImplement(this);
202  }
final SqlOperandTypeChecker operandTypeChecker

+ Here is the caller graph for this function:

SqlOperandTypeChecker org.apache.calcite.sql.SqlOperator.getOperandTypeChecker ( )
inline

Definition at line 182 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.operandTypeChecker.

Referenced by org.apache.calcite.sql2rel.StandardConvertletTable.convertCall().

182  {
183  return operandTypeChecker;
184  }
final SqlOperandTypeChecker operandTypeChecker

+ Here is the caller graph for this function:

SqlOperandTypeInference org.apache.calcite.sql.SqlOperator.getOperandTypeInference ( )
inline

Definition at line 758 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.operandTypeInference.

758  {
759  return operandTypeInference;
760  }
final SqlOperandTypeInference operandTypeInference
SqlReturnTypeInference org.apache.calcite.sql.SqlOperator.getReturnTypeInference ( )
inline

Returns the return type inference strategy for this operator, or null if return type inference is implemented by a subclass override.

Definition at line 895 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.returnTypeInference.

895  {
896  return returnTypeInference;
897  }
final SqlReturnTypeInference returnTypeInference
int org.apache.calcite.sql.SqlOperator.getRightPrec ( )
inline

Definition at line 235 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.rightPrec.

235  {
236  return rightPrec;
237  }
String org.apache.calcite.sql.SqlOperator.getSignatureTemplate ( final int  operandsCount)
inline

Returns a template describing how the operator signature is to be built. E.g for the binary + operator the template looks like "{1} {0} {2}" {0} is the operator, subsequent numbers are operands.

Parameters
operandsCountis used with functions that can take a variable number of operands
Returns
signature template, or null to indicate that a default template will suffice

Definition at line 733 of file SqlOperator.java.

733  {
734  return null;
735  }
Supplier<Strong.Policy> org.apache.calcite.sql.SqlOperator.getStrongPolicyInference ( )
inline

Returns the Strong.Policy strategy for this operator, or null if there is no particular strategy, in which case this policy will be deducted from the operator's SqlKind.

See Also
Strong

Definition at line 906 of file SqlOperator.java.

906  {
907  return null;
908  }
abstract SqlSyntax org.apache.calcite.sql.SqlOperator.getSyntax ( )
pure virtual

Returns the syntactic type of this operator, never null.

Referenced by org.apache.calcite.sql.SqlOperator.deriveType(), and org.apache.calcite.sql.SqlOperator.unparse().

+ Here is the caller graph for this function:

int org.apache.calcite.sql.SqlOperator.hashCode ( )
inline

Definition at line 395 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.kind, and org.apache.calcite.sql.SqlOperator.name.

395  {
396  return Objects.hash(kind, name);
397  }
RelDataType org.apache.calcite.sql.SqlOperator.inferReturnType ( SqlOperatorBinding  opBinding)
inline

Infers the return type of an invocation of this operator; only called after the number and types of operands have already been validated. Subclasses must either override this method or supply an instance of SqlReturnTypeInference to the constructor.

Parameters
opBindingdescription of invocation (not necessarily a SqlCall)
Returns
inferred return type

Definition at line 490 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.returnTypeInference.

Referenced by org.apache.calcite.sql.SqlOperator.inferReturnType(), and org.apache.calcite.sql.SqlOperator.validateOperands().

491  {
492  if (returnTypeInference != null) {
493  RelDataType returnType = returnTypeInference.inferReturnType(opBinding);
494  if (returnType == null) {
495  throw new IllegalArgumentException("Cannot infer return type for "
496  + opBinding.getOperator() + "; operand types: "
497  + opBinding.collectOperandTypes());
498  }
499  return returnType;
500  }
501 
502  // Derived type should have overridden this method, since it didn't
503  // supply a type inference rule.
504  throw Util.needToImplement(this);
505  }
final SqlReturnTypeInference returnTypeInference

+ Here is the caller graph for this function:

final RelDataType org.apache.calcite.sql.SqlOperator.inferReturnType ( RelDataTypeFactory  typeFactory,
List< RelDataType >  operandTypes 
)
inline

Infers the type of a call to this operator with a given set of operand types. Shorthand for inferReturnType(SqlOperatorBinding).

Definition at line 649 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.inferReturnType().

651  {
652  return inferReturnType(
653  new ExplicitOperatorBinding(
654  typeFactory,
655  this,
656  operandTypes));
657  }
RelDataType inferReturnType(SqlOperatorBinding opBinding)

+ Here is the call graph for this function:

boolean org.apache.calcite.sql.SqlOperator.isAggregator ( )
inline

Returns whether this operator is an aggregate function. By default, subclass type is used (an instance of SqlAggFunction is assumed to be an aggregator; anything else is not).

Per SQL:2011, there are aggregate functions and window functions. Every aggregate function (e.g. SUM) is also a window function. There are window functions that are not aggregate functions, e.g. RANK, NTILE, LEAD, FIRST_VALUE.

Collectively, aggregate and window functions are called analytic functions. Despite its name, this method returns true for every analytic function.

See Also
requiresOrder()
Returns
whether this operator is an analytic function (aggregate function or window function)

Definition at line 782 of file SqlOperator.java.

Referenced by org.apache.calcite.sql.validate.SqlValidatorImpl.validateExpr().

782  {
783  return false;
784  }

+ Here is the caller graph for this function:

boolean org.apache.calcite.sql.SqlOperator.isDeterministic ( )
inline

Returns whether a call to this operator is guaranteed to always return the same result given the same operands; true is assumed by default.

Definition at line 944 of file SqlOperator.java.

944  {
945  return true;
946  }
boolean org.apache.calcite.sql.SqlOperator.isDynamicFunction ( )
inline

Returns whether it is unsafe to cache query plans referencing this operator; false is assumed by default.

Definition at line 963 of file SqlOperator.java.

963  {
964  return false;
965  }
boolean org.apache.calcite.sql.SqlOperator.isGroup ( )
inline

Returns whether this is a group function.

Group functions can only appear in the GROUP BY clause.

Examples are

HOP

,

TUMBLE

,

SESSION

.

Group functions have auxiliary functions, e.g.

HOP_START

, but these are not group functions.

Definition at line 834 of file SqlOperator.java.

Referenced by org.apache.calcite.sql.validate.SqlValidatorImpl.validateNoAggs().

834  {
835  return false;
836  }

+ Here is the caller graph for this function:

boolean org.apache.calcite.sql.SqlOperator.isGroupAuxiliary ( )
inline

Returns whether this is an group auxiliary function.

Examples are

HOP_START

and

HOP_END

(both auxiliary to

HOP

).

See Also
isGroup()

Definition at line 846 of file SqlOperator.java.

846  {
847  return false;
848  }
boolean org.apache.calcite.sql.SqlOperator.isName ( String  testName,
boolean  caseSensitive 
)
inline

Definition at line 391 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.name.

391  {
392  return caseSensitive ? name.equals(testName) : name.equalsIgnoreCase(testName);
393  }
boolean org.apache.calcite.sql.SqlOperator.isSymmetrical ( )
inline

Returns whether a call to this operator is not sensitive to the operands input order. An operator is symmetrical if the call returns the same result when the operands are shuffled.

By default, returns true for SqlKind#SYMMETRICAL.

Definition at line 955 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.kind.

955  {
956  return SqlKind.SYMMETRICAL.contains(kind);
957  }
static int org.apache.calcite.sql.SqlOperator.leftPrec ( int  prec,
boolean  leftAssoc 
)
inlinestaticprotected

Definition at line 166 of file SqlOperator.java.

166  {
167  assert (prec % 2) == 0;
168  if (!leftAssoc) {
169  ++prec;
170  }
171  return prec;
172  }
boolean org.apache.calcite.sql.SqlOperator.needsSpace ( )
inlinepackage

Returns whether this operator should be surrounded by space when unparsed.

Returns
whether this operator should be surrounded by space

Definition at line 630 of file SqlOperator.java.

630  {
631  return true;
632  }
void org.apache.calcite.sql.SqlOperator.preValidateCall ( SqlValidator  validator,
SqlValidatorScope  scope,
SqlCall  call 
)
inlineprotected

Receives notification that validation of a call to this operator is beginning. Subclasses can supply custom behavior; default implementation does nothing.

Parameters
validatorinvoking validator
scopevalidation scope
callthe call being validated

Definition at line 474 of file SqlOperator.java.

Referenced by org.apache.calcite.sql.SqlOperator.validateOperands().

477  {
478  }

+ Here is the caller graph for this function:

boolean org.apache.calcite.sql.SqlOperator.requiresCreate ( List< SqlNode >  operands)
inline

Definition at line 208 of file SqlOperator.java.

208  { // HEAVY.AI new
209  return false; // HEAVY.AI new
210  } // HEAVY.AI new
boolean org.apache.calcite.sql.SqlOperator.requiresDecimalExpansion ( )
inline

Method to check if call requires expansion when it has decimal operands. The default implementation is to return true.

Definition at line 971 of file SqlOperator.java.

971  {
972  return true;
973  }
boolean org.apache.calcite.sql.SqlOperator.requiresOrder ( )
inline

Returns whether this is a window function that requires ordering.

Per SQL:2011, 2, 6.10: "If <ntile function>, <lead or lag function>, RANK or DENSE_RANK is specified, then the window ordering clause shall be present."

See Also
isAggregator()

Definition at line 812 of file SqlOperator.java.

812  {
813  return false;
814  }
boolean org.apache.calcite.sql.SqlOperator.requiresOver ( )
inline

Returns whether this is a window function that requires an OVER clause.

For example, returns true for

,

and other ranking functions; returns false for

,

,

,

,

(they can be used as non-window aggregate functions).

If

returns true, then isAggregator() must also return true.

See Also
allowsFraming()
requiresOrder()

Definition at line 799 of file SqlOperator.java.

799  {
800  return false;
801  }
SqlNode org.apache.calcite.sql.SqlOperator.rewriteCall ( SqlValidator  validator,
SqlCall  call 
)
inline

Rewrites a call to this operator. Some operators are implemented as trivial rewrites (e.g. NULLIF becomes CASE). However, we don't do this at createCall time because we want to preserve the original SQL syntax as much as possible; instead, we do this before the call is validated (so the trivial operator doesn't need its own implementation of type derivation methods). The default implementation is to just return the original call without any rewrite.

Parameters
validatorValidator
callCall to be rewritten
Returns
rewritten call

Definition at line 323 of file SqlOperator.java.

323  {
324  return call;
325  }
static int org.apache.calcite.sql.SqlOperator.rightPrec ( int  prec,
boolean  leftAssoc 
)
inlinestaticprotected

Definition at line 174 of file SqlOperator.java.

174  {
175  assert (prec % 2) == 0;
176  if (leftAssoc) {
177  ++prec;
178  }
179  return prec;
180  }
String org.apache.calcite.sql.SqlOperator.toString ( )
inline

Definition at line 227 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.name.

227  {
228  return name;
229  }
void org.apache.calcite.sql.SqlOperator.unparse ( SqlWriter  writer,
SqlCall  call,
int  leftPrec,
int  rightPrec 
)
inline

Writes a SQL representation of a call to this operator to a writer, including parentheses if the operators on either side are of greater precedence.

The default implementation of this method delegates to SqlSyntax#unparse.

Definition at line 335 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.getSyntax(), org.apache.calcite.sql.SqlOperator.leftPrec, and org.apache.calcite.sql.SqlOperator.rightPrec.

339  {
340  getSyntax().unparse(writer, this, call, leftPrec, rightPrec);
341  }
abstract SqlSyntax getSyntax()

+ Here is the call graph for this function:

void org.apache.calcite.sql.SqlOperator.unparseListClause ( SqlWriter  writer,
SqlNode  clause 
)
inlineprotected

Definition at line 344 of file SqlOperator.java.

344  {
345  final SqlNodeList nodeList =
346  clause instanceof SqlNodeList
347  ? (SqlNodeList) clause
348  : SqlNodeList.of(clause);
349  writer.list(SqlWriter.FrameTypeEnum.SIMPLE, SqlWriter.COMMA, nodeList);
350  }
void org.apache.calcite.sql.SqlOperator.unparseListClause ( SqlWriter  writer,
SqlNode  clause,
SqlKind  sepKind 
)
inlineprotected

Definition at line 353 of file SqlOperator.java.

356  {
357  final SqlNodeList nodeList =
358  clause instanceof SqlNodeList
359  ? (SqlNodeList) clause
360  : SqlNodeList.of(clause);
361  final SqlBinaryOperator sepOp;
362  if (sepKind == null) {
363  sepOp = SqlWriter.COMMA;
364  } else {
365  switch (sepKind) {
366  case AND:
367  sepOp = SqlStdOperatorTable.AND;
368  break;
369  case OR:
370  sepOp = SqlStdOperatorTable.OR;
371  break;
372  default:
373  throw new AssertionError();
374  }
375  }
376  writer.list(SqlWriter.FrameTypeEnum.SIMPLE, sepOp, nodeList);
377  }
void org.apache.calcite.sql.SqlOperator.validateCall ( SqlCall  call,
SqlValidator  validator,
SqlValidatorScope  scope,
SqlValidatorScope  operandScope 
)
inline

Validates a call to this operator.

This method should not perform type-derivation or perform validation related related to types. That is done later, by deriveType(SqlValidator, SqlValidatorScope, SqlCall). This method should focus on structural validation.

A typical implementation of this method first validates the operands, then performs some operator-specific logic. The default implementation just validates the operands.

This method is the default implementation of SqlCall#validate; but note that some sub-classes of SqlCall never call this method.

Parameters
callthe call to this operator
validatorthe active validator
scopevalidator scope
operandScopevalidator scope in which to validate operands to this call; usually equal to scope, but not always because some operators introduce new scopes
See Also
SqlNode::validateExpr(SqlValidator, SqlValidatorScope)
deriveType(SqlValidator, SqlValidatorScope, SqlCall)

Definition at line 423 of file SqlOperator.java.

427  {
428  assert call.getOperator() == this;
429  for (SqlNode operand : call.getOperandList()) {
430  operand.validateExpr(validator, operandScope);
431  }
432  }
final RelDataType org.apache.calcite.sql.SqlOperator.validateOperands ( SqlValidator  validator,
SqlValidatorScope  scope,
SqlCall  call 
)
inline

Validates the operands of a call, inferring the return type in the process.

Parameters
validatoractive validator
scopevalidation scope
callcall to be validated
Returns
inferred type

Definition at line 443 of file SqlOperator.java.

References org.apache.calcite.sql.SqlOperator.checkOperandCount(), org.apache.calcite.sql.SqlOperator.checkOperandTypes(), org.apache.calcite.sql.SqlOperator.inferReturnType(), org.apache.calcite.sql.SqlOperator.operandTypeChecker, and org.apache.calcite.sql.SqlOperator.preValidateCall().

Referenced by org.apache.calcite.sql.SqlOperator.deriveType().

446  {
447  // Let subclasses know what's up.
448  preValidateCall(validator, scope, call);
449 
450  // Check the number of operands
451  checkOperandCount(validator, operandTypeChecker, call);
452 
453  SqlCallBinding opBinding = new SqlCallBinding(validator, scope, call);
454 
456  opBinding,
457  true);
458 
459  // Now infer the result type.
460  RelDataType ret = inferReturnType(opBinding);
461  ((SqlValidatorImpl) validator).setValidatedNodeType(call, ret);
462  return ret;
463  }
boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure)
final SqlOperandTypeChecker operandTypeChecker
void preValidateCall(SqlValidator validator, SqlValidatorScope scope, SqlCall call)
void checkOperandCount(SqlValidator validator, SqlOperandTypeChecker argType, SqlCall call)
RelDataType inferReturnType(SqlOperatorBinding opBinding)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

boolean org.apache.calcite.sql.SqlOperator.validRexOperands ( int  count,
Litmus  litmus 
)
inline

Returns whether the given operands are valid. If not valid and

fail

, throws an assertion error.

Similar to checkOperandCount, but some operators may have different valid operands in SqlNode and

RexNode

formats (some examples are CAST and AND), and this method throws internal errors, not user errors.

Definition at line 719 of file SqlOperator.java.

719  {
720  return true;
721  }

Member Data Documentation

final int org.apache.calcite.sql.SqlOperator.leftPrec
private

The precedence with which this operator binds to the expression to the left. This is less than the right precedence if the operator is left-associative.

Definition at line 102 of file SqlOperator.java.

Referenced by org.apache.calcite.sql.SqlOperator.getLeftPrec(), org.apache.calcite.sql.SqlOperator.SqlOperator(), and org.apache.calcite.sql.SqlOperator.unparse().

final int org.apache.calcite.sql.SqlOperator.MDX_PRECEDENCE = 200
static

Maximum precedence.

Definition at line 82 of file SqlOperator.java.

final String org.apache.calcite.sql.SqlOperator.NL = System.getProperty("line.separator")
static

Definition at line 77 of file SqlOperator.java.

final SqlOperandTypeInference org.apache.calcite.sql.SqlOperator.operandTypeInference
private

Used to infer types of unknown operands.

Definition at line 115 of file SqlOperator.java.

Referenced by org.apache.calcite.sql.SqlOperator.getOperandTypeInference(), and org.apache.calcite.sql.SqlOperator.SqlOperator().

final SqlReturnTypeInference org.apache.calcite.sql.SqlOperator.returnTypeInference
private
final int org.apache.calcite.sql.SqlOperator.rightPrec
private

The precedence with which this operator binds to the expression to the right. This is more than the left precedence if the operator is left-associative.

Definition at line 109 of file SqlOperator.java.

Referenced by org.apache.calcite.sql.SqlOperator.getRightPrec(), org.apache.calcite.sql.SqlOperator.SqlOperator(), and org.apache.calcite.sql.SqlOperator.unparse().


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