org.eigenbase.sql.fun
Class SqlCastFunction

java.lang.Object
  extended by org.eigenbase.sql.SqlOperator
      extended by org.eigenbase.sql.SqlFunction
          extended by org.eigenbase.sql.fun.SqlCastFunction

public class SqlCastFunction
extends SqlFunction

SqlCastFunction. Note that the std functions are really singleton objects, because they always get fetched via the StdOperatorTable. So you can't store any local info in the class and hence the return type data is maintained in operand[1] through the validation phase.

Since:
Jun 5, 2004
Version:
$Id: //open/dev/farrago/src/org/eigenbase/sql/fun/SqlCastFunction.java#24 $
Author:
lee

Nested Class Summary
private  class SqlCastFunction.TypeFamilyCast
           
 
Field Summary
private  Set<SqlCastFunction.TypeFamilyCast> nonMonotonicPreservingCasts
           
 
Fields inherited from class org.eigenbase.sql.SqlOperator
MaxPrec, NL
 
Constructor Summary
SqlCastFunction()
           
 
Method Summary
 boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure)
          Makes sure that the number and types of arguments are allowable.
private  Set<SqlCastFunction.TypeFamilyCast> createNonMonotonicPreservingCasts()
           
 SqlMonotonicity getMonotonicity(SqlCall call, SqlValidatorScope scope)
          Returns whether this operator is monotonic.
 SqlOperandCountRange getOperandCountRange()
          Returns a constraint on the number of operands expected by this operator.
 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.
 RelDataType inferReturnType(SqlOperatorBinding opBinding)
          Infers the return type of an invocation of this operator; only called after the number and types of operands have already been validated.
private  boolean isMonotonicPreservingCast(RelDataTypeFamily castFrom, RelDataTypeFamily castTo)
           
 void unparse(SqlWriter writer, SqlNode[] operands, int leftPrec, int rightPrec)
          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.
 
Methods inherited from class org.eigenbase.sql.SqlFunction
deriveType, getFunctionType, getNameAsId, getParamTypes, getSqlIdentifier, isQuantifierAllowed, validateCall, validateQuantifier
 
Methods inherited from class org.eigenbase.sql.SqlOperator
acceptCall, acceptCall, adjustType, argumentMustBeScalar, checkOperandCount, createCall, createCall, createCall, createCall, equals, getAllowedSignatures, getAllowedSignatures, getKind, getLeftPrec, getName, getOperandTypeChecker, getOperandTypeInference, getReturnTypeInference, getRightPrec, hashCode, inferReturnType, isAggregator, isDeterministic, isDynamicFunction, isName, leftPrec, preValidateCall, requiresDecimalExpansion, rewriteCall, rightPrec, toString, unparseListClause, unparseListClause, validateOperands
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

nonMonotonicPreservingCasts

private final Set<SqlCastFunction.TypeFamilyCast> nonMonotonicPreservingCasts
Constructor Detail

SqlCastFunction

public SqlCastFunction()
Method Detail

createNonMonotonicPreservingCasts

private Set<SqlCastFunction.TypeFamilyCast> createNonMonotonicPreservingCasts()

isMonotonicPreservingCast

private boolean isMonotonicPreservingCast(RelDataTypeFamily castFrom,
                                          RelDataTypeFamily castTo)

inferReturnType

public RelDataType inferReturnType(SqlOperatorBinding opBinding)
Description copied from class: SqlOperator
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.

Overrides:
inferReturnType in class SqlOperator
Parameters:
opBinding - description of invocation (not necessarily a SqlCall)
Returns:
inferred return type

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

getOperandCountRange

public SqlOperandCountRange getOperandCountRange()
Description copied from class: SqlOperator
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.

Overrides:
getOperandCountRange in class SqlOperator
Returns:
acceptable range

checkOperandTypes

public boolean checkOperandTypes(SqlCallBinding callBinding,
                                 boolean throwOnFailure)
Makes sure that the number and types of arguments are allowable. Operators (such as "ROW" and "AS") which do not check their arguments can override this method.

Overrides:
checkOperandTypes in class SqlOperator
Parameters:
callBinding - description of call
throwOnFailure - whether to throw an exception if check fails (otherwise returns false in that case)
Returns:
whether check succeeded

getSyntax

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

Overrides:
getSyntax in class SqlFunction

unparse

public void unparse(SqlWriter writer,
                    SqlNode[] operands,
                    int leftPrec,
                    int rightPrec)
Description copied from class: SqlOperator
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(org.eigenbase.sql.SqlWriter, org.eigenbase.sql.SqlOperator, org.eigenbase.sql.SqlNode[], int, int).

Overrides:
unparse in class SqlFunction

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