Search in sources :

Example 71 with DataTypeDescriptor

use of org.apache.derby.iapi.types.DataTypeDescriptor in project derby by apache.

the class UserAggregateDefinition method castInputValue.

/**
 * Wrap the input operand in an implicit CAST node as necessary in order to
 * coerce it the correct type for the aggregator. Return null if no cast is necessary.
 */
final ValueNode castInputValue(ValueNode inputValue, ContextManager cm) throws StandardException {
    AggregateAliasInfo aai = (AggregateAliasInfo) _alias.getAliasInfo();
    DataTypeDescriptor expectedInputType = DataTypeDescriptor.getType(aai.getForType());
    DataTypeDescriptor actualInputType = inputValue.getTypeServices();
    // no cast needed if the types match exactly
    if (expectedInputType.isExactTypeAndLengthMatch(actualInputType)) {
        return null;
    } else {
        return StaticMethodCallNode.makeCast(inputValue, expectedInputType, cm);
    }
}
Also used : DataTypeDescriptor(org.apache.derby.iapi.types.DataTypeDescriptor) AggregateAliasInfo(org.apache.derby.catalog.types.AggregateAliasInfo)

Example 72 with DataTypeDescriptor

use of org.apache.derby.iapi.types.DataTypeDescriptor in project derby by apache.

the class ValueNode method genEqualsFalseTree.

/**
 * Transform this into this = false.  Useful for NOT elimination.
 *
 * @return		The modified expression
 *
 * @exception StandardException		Thrown on error
 */
ValueNode genEqualsFalseTree() throws StandardException {
    BinaryRelationalOperatorNode equalsNode;
    BooleanConstantNode falseNode;
    boolean nullableResult;
    falseNode = new BooleanConstantNode(false, getContextManager());
    equalsNode = new BinaryRelationalOperatorNode(BinaryRelationalOperatorNode.K_EQUALS, this, falseNode, false, getContextManager());
    nullableResult = getTypeServices().isNullable();
    equalsNode.setType(new DataTypeDescriptor(TypeId.BOOLEAN_ID, nullableResult));
    return equalsNode;
}
Also used : DataTypeDescriptor(org.apache.derby.iapi.types.DataTypeDescriptor)

Example 73 with DataTypeDescriptor

use of org.apache.derby.iapi.types.DataTypeDescriptor in project derby by apache.

the class ValueNode method genIsNullTree.

/**
 * Transform this into this IS NULL or IS NOT NULL.
 *
 * @param notNull if true, transform this into IS NOT NULL;
 *                otherwise, transform this into IS NULL
 * @return		The modified expression
 *
 * @exception StandardException		Thrown on error
 */
ValueNode genIsNullTree(boolean notNull) throws StandardException {
    IsNullNode isNullNode;
    isNullNode = new IsNullNode(this, notNull, getContextManager());
    isNullNode.setType(new DataTypeDescriptor(TypeId.BOOLEAN_ID, false));
    return isNullNode;
}
Also used : DataTypeDescriptor(org.apache.derby.iapi.types.DataTypeDescriptor)

Example 74 with DataTypeDescriptor

use of org.apache.derby.iapi.types.DataTypeDescriptor in project derby by apache.

the class ValueNodeList method getTypeServices.

/**
 * Get the first non-null DataTypeServices from the elements in the list.
 *
 * @return DataTypeServices		The first non-null DataTypeServices.
 *
 * @exception StandardException		Thrown on error
 */
DataTypeDescriptor getTypeServices() throws StandardException {
    int size = size();
    for (int index = 0; index < size; index++) {
        ValueNode valueNode = elementAt(index);
        DataTypeDescriptor valueNodeDTS = valueNode.getTypeServices();
        if (valueNodeDTS != null) {
            return valueNodeDTS;
        }
    }
    return null;
}
Also used : DataTypeDescriptor(org.apache.derby.iapi.types.DataTypeDescriptor)

Example 75 with DataTypeDescriptor

use of org.apache.derby.iapi.types.DataTypeDescriptor in project derby by apache.

the class ValueNodeList method allSamePrecendence.

/**
 * Return whether or not all of the entries in the list have the same
 * type precendence as the specified value.
 *
 * @param precedence	The specified precedence.
 *
 * @return	Whether or not all of the entries in the list have the same
 *			type precendence as the specified value.
 */
boolean allSamePrecendence(int precedence) {
    boolean allSame = true;
    int size = size();
    for (int index = 0; index < size; index++) {
        ValueNode valueNode;
        valueNode = elementAt(index);
        DataTypeDescriptor valueNodeDTS = valueNode.getTypeServices();
        if (valueNodeDTS == null) {
            return false;
        }
        if (precedence != valueNodeDTS.getTypeId().typePrecedence()) {
            return false;
        }
    }
    return allSame;
}
Also used : DataTypeDescriptor(org.apache.derby.iapi.types.DataTypeDescriptor)

Aggregations

DataTypeDescriptor (org.apache.derby.iapi.types.DataTypeDescriptor)99 TypeId (org.apache.derby.iapi.types.TypeId)32 ColumnDescriptor (org.apache.derby.iapi.sql.dictionary.ColumnDescriptor)14 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)14 CompilerContext (org.apache.derby.iapi.sql.compile.CompilerContext)9 SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)8 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)8 TypeDescriptor (org.apache.derby.catalog.TypeDescriptor)7 UUID (org.apache.derby.catalog.UUID)5 ClassFactory (org.apache.derby.iapi.services.loader.ClassFactory)5 ResultColumnDescriptor (org.apache.derby.iapi.sql.ResultColumnDescriptor)5 TypeCompiler (org.apache.derby.iapi.sql.compile.TypeCompiler)5 StandardException (org.apache.derby.shared.common.error.StandardException)5 Properties (java.util.Properties)4 UserDefinedTypeIdImpl (org.apache.derby.catalog.types.UserDefinedTypeIdImpl)4 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)4 AliasDescriptor (org.apache.derby.iapi.sql.dictionary.AliasDescriptor)3 ColumnDescriptorList (org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList)3 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)3 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)3