Package com.foundationdb.sql.types

Examples of com.foundationdb.sql.types.DataTypeDescriptor


     *
     * @return the corresponding compilation type id
     *
     */
    public TypeId mapToTypeID(JSQLType jsqlType) throws StandardException {
        DataTypeDescriptor dts = jsqlType.getSQLType();

        if (dts == null) {
            return null;
        }

        return dts.getTypeId();
    }
View Full Code Here


                boolean definersRights  = (definersRightsO == null) ? false : definersRightsO.booleanValue();

                Boolean calledOnNullInputO = (Boolean)routineElements[NULL_ON_NULL_INPUT];
                boolean calledOnNullInput = (calledOnNullInputO == null) ? false : calledOnNullInputO.booleanValue();

                DataTypeDescriptor returnType = (DataTypeDescriptor)routineElements[RETURN_TYPE];

                String language = (String)routineElements[LANGUAGE];
                String pstyle = (String)routineElements[PARAMETER_STYLE];
               
                this.definition = (String)routineElements[INLINE_DEFINITION];
View Full Code Here

    /**
     * Set this node's type from type components.
     */
    final void setType(TypeId typeId, boolean isNullable, int maximumWidth)
            throws StandardException {
        setType(new DataTypeDescriptor(typeId, isNullable, maximumWidth));
    }
View Full Code Here

     */
    final void setType(TypeId typeId,
                       int precision, int scale,
                       boolean isNullable, int maximumWidth)
            throws StandardException {
        setType(new DataTypeDescriptor(typeId,
                                       precision, scale,
                                       isNullable, maximumWidth));    
    }
View Full Code Here

                     Object precision,
                     Object scale,
                     Object isNullable,
                     Object maximumWidth)
            throws StandardException {
        setType(new DataTypeDescriptor((TypeId)typeId,
                                       ((Integer)precision).intValue(),
                                       ((Integer)scale).intValue(),
                                       ((Boolean)isNullable).booleanValue(),
                                       ((Integer)maximumWidth).intValue()));
    }
View Full Code Here

     *
     * @return The TypeId from this ValueNode.  This
     *               may be null if the node isn't bound yet.
     */
    public TypeId getTypeId() throws StandardException {
        DataTypeDescriptor dtd = getType();
        if (dtd != null)
            return dtd.getTypeId();
        return null;
    }
View Full Code Here

    protected DataTypeDescriptor inListOperatorNode(InListOperatorNode node) throws StandardException {
        RowConstructorNode leftOperand = node.getLeftOperand();
       
        if (leftOperand.getNodeList().size() == 1)
        {
            DataTypeDescriptor leftType = leftOperand.getNodeList().get(0).getType();
            if (leftType == null)
                return null;

            boolean nullableResult = leftType.isNullable();

            for (ValueNode rightOperand : node.getRightOperandList().getNodeList()) {
                DataTypeDescriptor rightType;
                if (isParameterOrUntypedNull(rightOperand)) {
                    rightType = leftType.getNullabilityType(true);
                    rightOperand.setType(rightType);
                }
                else {
                    rightType = rightOperand.getType();
                }
                if ((rightType == null) || rightType.isNullable())
                    nullableResult = true;
            }
            return new DataTypeDescriptor(TypeId.BOOLEAN_ID, nullableResult);
        }
        else
        {
            boolean nullable = isNestedTupleNullable(leftOperand)
                                || isNestedTupleNullable(node.getRightOperandList());
           
            return new DataTypeDescriptor(TypeId.BOOLEAN_ID, nullable);
        }
    }
View Full Code Here

        return ret;
    }

    protected DataTypeDescriptor subqueryNode(SubqueryNode node) throws StandardException {
        if (node.getSubqueryType() == SubqueryNode.SubqueryType.EXPRESSION) {
            DataTypeDescriptor col1Type = node.getResultSet().getResultColumns().get(0).getType();
            if (col1Type == null)
                return null;
            else
                return col1Type.getNullabilityType(true);
        }
        else
            return new DataTypeDescriptor(TypeId.BOOLEAN_ID, true);
    }
View Full Code Here

    protected DataTypeDescriptor aggregateNode(AggregateNode node)
            throws StandardException {
        if (node.getAggregateName().equals("COUNT") ||
            node.getAggregateName().equals("COUNT(*)"))
            return new DataTypeDescriptor(TypeId.BIGINT_ID, false);

        ValueNode operand = node.getOperand();
        if ((operand == null) ||
            (operand.getType() == null))
            return null;
        if (node.getAggregateName().equals("AVG") &&
            operand.getType().getTypeId().isIntegerTypeId())
            return new DataTypeDescriptor(TypeId.DOUBLE_ID, true);
        return operand.getType().getNullabilityType(true);
    }
View Full Code Here

    protected DataTypeDescriptor concatenationOperatorNode(ConcatenationOperatorNode node)
            throws StandardException {
        ValueNode leftOperand = node.getLeftOperand();
        ValueNode rightOperand = node.getRightOperand();
        DataTypeDescriptor leftType = leftOperand.getType();
        DataTypeDescriptor rightType = rightOperand.getType();
        if ((leftType != null) &&
            !leftType.getTypeId().isStringTypeId()) {
            leftType = new DataTypeDescriptor(TypeId.VARCHAR_ID,
                                              leftType.isNullable(),
                                              leftType.getMaximumWidth());
            leftOperand = (ValueNode)node.getNodeFactory()
                .getNode(NodeTypes.CAST_NODE,
                         leftOperand, leftType,
                         node.getParserContext());
            node.setLeftOperand(leftOperand);
        }
        else if (isParameterOrUntypedNull(leftOperand)) {
            leftType = new DataTypeDescriptor(TypeId.VARCHAR_ID, true);
            leftOperand.setType(leftType);
        }
        if ((rightType != null) &&
            !rightType.getTypeId().isStringTypeId()) {
            rightType = new DataTypeDescriptor(TypeId.VARCHAR_ID,
                                              rightType.isNullable(),
                                              rightType.getMaximumWidth());
            rightOperand = (ValueNode)node.getNodeFactory()
                .getNode(NodeTypes.CAST_NODE,
                         rightOperand, rightType,
                         node.getParserContext());
            node.setRightOperand(rightOperand);
        }
        else if (isParameterOrUntypedNull(rightOperand)) {
            rightType = new DataTypeDescriptor(TypeId.VARCHAR_ID, true);
            rightOperand.setType(rightType);
        }
        if ((leftType == null) || (rightType == null))
            return null;
        return new DataTypeDescriptor(TypeId.VARCHAR_ID,
                                      leftType.isNullable() || rightType.isNullable(),
                                      leftType.getMaximumWidth() + rightType.getMaximumWidth(),
                                      CharacterTypeAttributes.mergeCollations(leftType.getCharacterAttributes(), rightType.getCharacterAttributes()));
    }
View Full Code Here

TOP

Related Classes of com.foundationdb.sql.types.DataTypeDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.