org.eigenbase.sql
Class SqlBinaryOperator

java.lang.Object
  extended by org.eigenbase.sql.SqlOperator
      extended by org.eigenbase.sql.SqlBinaryOperator
Direct Known Subclasses:
SqlInOperator, SqlMonotonicBinaryOperator, SqlMultisetMemberOfOperator, SqlMultisetSetOperator, SqlOverOperator, SqlSetOperator

public class SqlBinaryOperator
extends SqlOperator

SqlBinaryOperator is a binary operator.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/sql/SqlBinaryOperator.java#16 $

Field Summary
 
Fields inherited from class org.eigenbase.sql.SqlOperator
MaxPrec, NL
 
Constructor Summary
SqlBinaryOperator(String name, SqlKind kind, int prec, boolean leftAssoc, SqlReturnTypeInference returnTypeInference, SqlOperandTypeInference operandTypeInference, SqlOperandTypeChecker operandTypeChecker)
          Creates a SqlBinaryOperator.
 
Method Summary
protected  RelDataType adjustType(SqlValidator validator, SqlCall call, RelDataType type)
          Validates and determines coercibility and resulting collation name of binary operator if needed.
 RelDataType deriveType(SqlValidator validator, SqlValidatorScope scope, SqlCall call)
          Derives the type of a call to this operator.
 SqlMonotonicity getMonotonicity(SqlCall call, SqlValidatorScope scope)
          Returns whether this operator is monotonic.
 String getSignatureTemplate(int operandsCount)
          Returns a template describing how the operator signature is to be built.
 SqlSyntax getSyntax()
          Returns the syntactic type of this operator.
(package private)  boolean needsSpace()
          Returns whether this operator should be surrounded by space when unparsed.
 
Methods inherited from class org.eigenbase.sql.SqlOperator
acceptCall, acceptCall, argumentMustBeScalar, checkOperandCount, checkOperandTypes, createCall, createCall, createCall, createCall, equals, getAllowedSignatures, getAllowedSignatures, getKind, getLeftPrec, getName, getOperandCountRange, getOperandTypeChecker, getOperandTypeInference, getReturnTypeInference, getRightPrec, hashCode, inferReturnType, inferReturnType, isAggregator, isDeterministic, isDynamicFunction, isName, leftPrec, preValidateCall, requiresDecimalExpansion, rewriteCall, rightPrec, toString, unparse, unparseListClause, unparseListClause, validateCall, validateOperands
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SqlBinaryOperator

public SqlBinaryOperator(String name,
                         SqlKind kind,
                         int prec,
                         boolean leftAssoc,
                         SqlReturnTypeInference returnTypeInference,
                         SqlOperandTypeInference operandTypeInference,
                         SqlOperandTypeChecker operandTypeChecker)
Creates a SqlBinaryOperator.

Parameters:
name - Name of operator
kind - Kind
prec - Precedence
leftAssoc - Left-associativity
returnTypeInference - Strategy to infer return type
operandTypeInference - Strategy to infer operand types
operandTypeChecker - Validator for operand types
Method Detail

getSyntax

public SqlSyntax getSyntax()
Description copied from class: SqlOperator
Returns the syntactic type of this operator.

Specified by:
getSyntax in class SqlOperator

getSignatureTemplate

public String getSignatureTemplate(int operandsCount)
Description copied from class: SqlOperator
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.

Overrides:
getSignatureTemplate in class SqlOperator
Parameters:
operandsCount - is used with functions that can take a variable number of operands
Returns:
signature template, or null to indicate that a default template will suffice

needsSpace

boolean needsSpace()
Returns whether this operator should be surrounded by space when unparsed.

Returns true for most operators but false for the '.' operator; consider

x.y + 5 * 6

Returns:
whether this operator should be surrounded by space

adjustType

protected RelDataType adjustType(SqlValidator validator,
                                 SqlCall call,
                                 RelDataType type)
Description copied from class: SqlOperator
Validates and determines coercibility and resulting collation name of binary operator if needed.

Overrides:
adjustType in class SqlOperator

deriveType

public RelDataType deriveType(SqlValidator validator,
                              SqlValidatorScope scope,
                              SqlCall call)
Description copied from class: SqlOperator
Derives the type of a call to this operator.

This method is an intrinsic part of the validation process so, unlike SqlOperator.inferReturnType(org.eigenbase.sql.SqlOperatorBinding), specific operators would not typically override this method.

Overrides:
deriveType in class SqlOperator
Parameters:
validator - Validator
scope - Scope of validation
call - Call to this operator
Returns:
Type of call

getMonotonicity

public SqlMonotonicity getMonotonicity(SqlCall call,
                                       SqlValidatorScope scope)
Description copied from class: SqlOperator
Returns whether this operator is monotonic.

Default implementation returns SqlMonotonicity.NotMonotonic.

Overrides:
getMonotonicity in class SqlOperator
Parameters:
call - Call to this operator
scope - Scope in which the call occurs