org.eigenbase.sql.fun
Class SqlLiteralChainOperator

java.lang.Object
  extended by org.eigenbase.sql.SqlOperator
      extended by org.eigenbase.sql.SqlSpecialOperator
          extended by org.eigenbase.sql.SqlInternalOperator
              extended by org.eigenbase.sql.fun.SqlLiteralChainOperator

public class SqlLiteralChainOperator
extends SqlInternalOperator

Internal operator, by which the parser represents a continued string literal.

The string fragments are SqlLiteral objects, all of the same type, collected as the operands of an SqlCall using this operator. After validation, the fragments will be concatenated into a single literal.

For a chain of SqlCharStringLiteral objects, a SqlCollation object is attached only to the head of the chain.

Since:
Sep 7, 2004
Version:
$Id: //open/dev/farrago/src/org/eigenbase/sql/fun/SqlLiteralChainOperator.java#22 $
Author:
Marc Berkowitz

Field Summary
 
Fields inherited from class org.eigenbase.sql.SqlOperator
MaxPrec, NL
 
Constructor Summary
SqlLiteralChainOperator()
           
 
Method Summary
private  boolean argTypesValid(SqlCallBinding callBinding)
           
 boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure)
          Checks that the operand values in a SqlCall to this operator are valid.
static SqlLiteral concatenateOperands(SqlCall call)
          Concatenates the operands of a call to this operator.
 String getAllowedSignatures(String opName)
          Returns a string describing the expected operand types of a call, e.g.
 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.
 void unparse(SqlWriter writer, SqlNode[] rands, 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.
 void validateCall(SqlCall call, SqlValidator validator, SqlValidatorScope scope, SqlValidatorScope operandScope)
          Validates a call to this operator.
 
Methods inherited from class org.eigenbase.sql.SqlInternalOperator
getSyntax
 
Methods inherited from class org.eigenbase.sql.SqlSpecialOperator
reduceExpr
 
Methods inherited from class org.eigenbase.sql.SqlOperator
acceptCall, acceptCall, adjustType, argumentMustBeScalar, checkOperandCount, createCall, createCall, createCall, createCall, deriveType, equals, getAllowedSignatures, getKind, getLeftPrec, getMonotonicity, getName, getOperandCountRange, getOperandTypeChecker, getOperandTypeInference, getReturnTypeInference, getRightPrec, getSignatureTemplate, 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
 

Constructor Detail

SqlLiteralChainOperator

SqlLiteralChainOperator()
Method Detail

argTypesValid

private boolean argTypesValid(SqlCallBinding callBinding)

checkOperandTypes

public boolean checkOperandTypes(SqlCallBinding callBinding,
                                 boolean throwOnFailure)
Description copied from class: SqlOperator
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.

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

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

getAllowedSignatures

public String getAllowedSignatures(String opName)
Description copied from class: SqlOperator
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 specifed name.

Overrides:
getAllowedSignatures in class SqlOperator

validateCall

public void validateCall(SqlCall call,
                         SqlValidator validator,
                         SqlValidatorScope scope,
                         SqlValidatorScope operandScope)
Description copied from class: SqlOperator
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 SqlOperator.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(org.eigenbase.sql.validate.SqlValidator, org.eigenbase.sql.validate.SqlValidatorScope); but note that some sub-classes of SqlCall never call this method.

Overrides:
validateCall in class SqlOperator
Parameters:
call - the call to this operator
validator - the active validator
scope - validator scope
operandScope - validator 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), SqlOperator.deriveType(SqlValidator, SqlValidatorScope, SqlCall)

unparse

public void unparse(SqlWriter writer,
                    SqlNode[] rands,
                    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 SqlInternalOperator

concatenateOperands

public static SqlLiteral concatenateOperands(SqlCall call)
Concatenates the operands of a call to this operator.