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);
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations