Package com.foundationdb.sql.types

Examples of com.foundationdb.sql.types.DataTypeDescriptor


            }
        }
    }

    private static void markNotNull(ColumnExpression columnExpression) {
        DataTypeDescriptor sqLtype = columnExpression.getSQLtype();
        if (sqLtype.isNullable()) {
            DataTypeDescriptor notNullable = sqLtype.getNullabilityType(false);
            columnExpression.setSQLtype(notNullable);
        }
    }
View Full Code Here


        JDBCParameterMetaData parameterMetaData = null;
        if (result.getParameterTypes() != null) {
            List<ParameterType> jdbcParams = new ArrayList<>();
            for (BasePlannable.ParameterType paramType : result.getParameterTypes()) {
                int jdbcType = Types.OTHER;
                DataTypeDescriptor sqlType = paramType.getSQLType();
                TInstance type = paramType.getType();
                if (type != null) {
                    jdbcType = TInstance.tClass(type).jdbcType();
                }
                else if (sqlType != null) {
                    jdbcType = sqlType.getJDBCTypeId();
                }
                jdbcParams.add(new ParameterType(sqlType, jdbcType, type));
            }
            parameterMetaData = new JDBCParameterMetaData(getTypesTranslator(), jdbcParams);
            if (getParameterNames) {
View Full Code Here

        // [BIG]INT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1)
        boolean isSerial = "serial".equalsIgnoreCase(typeName);
        boolean isBigSerial = "bigserial".equalsIgnoreCase(typeName);
        if (isSerial || isBigSerial) {
            // [BIG]INT NOT NULL
            DataTypeDescriptor typeDesc = new DataTypeDescriptor(isBigSerial ? TypeId.BIGINT_ID : TypeId.INTEGER_ID, false);
            addColumn (builder, typesTranslator,
                       schemaName, tableName, cdn.getColumnName(), colpos,
                       typeDesc, null, null);
            // GENERATED BY DEFAULT AS IDENTITY
            setAutoIncrement (builder, schemaName, tableName, cdn.getColumnName(), true, 1, 1);
View Full Code Here

                if (resultColumn.getPostgresType() != null) {
                    encoder.appendString(",\"oid\":");
                    encoder.getWriter().print(resultColumn.getPostgresType().getOid());
                }
                if (resultColumn.getSqlType() != null) {
                    DataTypeDescriptor type = resultColumn.getSqlType();
                    encoder.appendString(",\"type\":\"");
                    Quote.DOUBLE_QUOTE.append(appender, type.toString());
                    encoder.appendString("\"");
                    TypeId typeId = type.getTypeId();
                    if (typeId.isDecimalTypeId()) {
                        encoder.appendString(",\"precision\":");
                        encoder.getWriter().print(type.getPrecision());
                        encoder.appendString(",\"scale\":");
                        encoder.getWriter().print(type.getScale());
                    }
                    else if (typeId.variableLength()) {
                        encoder.appendString(",\"length\":");
                        encoder.getWriter().print(type.getMaximumWidth());
                    }
                }
            }
            encoder.appendString("}");
        }
View Full Code Here

        }
    }
   
    public static DataTypeDescriptor getType(Column column, boolean nullable)
            throws StandardException {
        DataTypeDescriptor type = column.getType().dataTypeDescriptor();
        if (nullable)
            type = type.getNullabilityType(nullable);
        return type;
    }
View Full Code Here

            }
            catch (StandardException ex) {
                throw new SQLParserInternalException(ex);
            }
        }
        DataTypeDescriptor sqlType;
        if (typeId.isDecimalTypeId() || typeId.isNumericTypeId()) {
            sqlType = new DataTypeDescriptor(typeId,
                                             metaData.getPrecision(columnIndex),
                                             metaData.getScale(columnIndex),
                                             metaData.isNullable(columnIndex) != ResultSetMetaData.columnNoNulls,
                                             metaData.getColumnDisplaySize(columnIndex));
        }
        else {
            sqlType = new DataTypeDescriptor(typeId,
                                             metaData.isNullable(columnIndex) != ResultSetMetaData.columnNoNulls,
                                             metaData.getColumnDisplaySize(columnIndex));
        }
        TInstance type = typesTranslator.typeForSQLType(sqlType);
        return PostgresType.fromDerby(sqlType, type);
View Full Code Here

                throw new SetWrongNumColumns (((ResultSet)left).getFields().size(),((ResultSet)right).getFields().size());
            }
            Project leftProject = getProject(left);
            Project rightProject= getProject(right);
            for (int i= 0; i < setNode.getResultColumns().size(); i++) {
                DataTypeDescriptor leftType = leftProject.getFields().get(i).getSQLtype();
                DataTypeDescriptor rightType = rightProject.getFields().get(i).getSQLtype();
                DataTypeDescriptor projectType = null;
                Project useProject = leftProject;
                // Case of SELECT null setNode SELECT null -> pick a type
                if (leftType == null && rightType == null) {
                    projectType = new DataTypeDescriptor (TypeId.VARCHAR_ID, true);
                } else if (leftType == null) {
                    projectType = rightType;
                    useProject = rightProject;
                } else if (rightType == null) {
                    projectType = leftType;
View Full Code Here

         */
        protected void addCondition(List<ConditionExpression> conditions,
                                    ValueNode condition,
                                    List<ExpressionNode> projects)
                throws StandardException {
            DataTypeDescriptor conditionType = null;
            TInstance conditionInst = null;
            switch (condition.getNodeType()) {
            case NodeTypes.BINARY_EQUALS_OPERATOR_NODE:
                addComparisonCondition(conditions, projects,
                                       (BinaryOperatorNode)condition, Comparison.EQ);
                return;
            case NodeTypes.BINARY_GREATER_THAN_OPERATOR_NODE:
                addComparisonCondition(conditions, projects,
                                       (BinaryOperatorNode)condition, Comparison.GT);
                return;
            case NodeTypes.BINARY_GREATER_EQUALS_OPERATOR_NODE:
                addComparisonCondition(conditions, projects,
                                       (BinaryOperatorNode)condition, Comparison.GE);
                return;
            case NodeTypes.BINARY_LESS_THAN_OPERATOR_NODE:
                addComparisonCondition(conditions, projects,
                                       (BinaryOperatorNode)condition, Comparison.LT);
                return;
            case NodeTypes.BINARY_LESS_EQUALS_OPERATOR_NODE:
                addComparisonCondition(conditions, projects,
                                       (BinaryOperatorNode)condition, Comparison.LE);
                return;
            case NodeTypes.BINARY_NOT_EQUALS_OPERATOR_NODE:
                addComparisonCondition(conditions, projects,
                                       (BinaryOperatorNode)condition, Comparison.NE);
                return;
            case NodeTypes.BETWEEN_OPERATOR_NODE:
                addBetweenCondition(conditions, projects,
                                    (BetweenOperatorNode)condition);
                return;
            case NodeTypes.IN_LIST_OPERATOR_NODE:
                addInCondition(conditions, projects,
                               (InListOperatorNode)condition);
                return;
            case NodeTypes.SUBQUERY_NODE:
                addSubqueryCondition(conditions, projects,
                                     (SubqueryNode)condition);
                return;
            case NodeTypes.LIKE_OPERATOR_NODE:
                addFunctionCondition(conditions, projects,
                                     (TernaryOperatorNode)condition);
                return;
            case NodeTypes.IS_NULL_NODE:
            case NodeTypes.IS_NOT_NULL_NODE:
                addIsNullCondition(conditions, projects,
                                   (IsNullNode)condition);
                return;
            case NodeTypes.IS_NODE:
                addIsCondition(conditions, projects,
                               (IsNode)condition);
                return;
            case NodeTypes.OR_NODE:
            case NodeTypes.AND_NODE:
            case NodeTypes.NOT_NODE:
                addLogicalFunctionCondition(conditions, projects, condition);
                return;
            case NodeTypes.BOOLEAN_CONSTANT_NODE:
                conditions.add(new BooleanConstantExpression(((BooleanConstantNode)condition).getBooleanValue()));
                return;
            case NodeTypes.UNTYPED_NULL_CONSTANT_NODE:
                conditions.add(new BooleanConstantExpression(null));
                return;
            case NodeTypes.PARAMETER_NODE:
                assert (parameters != null) && parameters.contains(condition) : condition;
                conditionType = condition.getType();
                if (conditionType == null) {
                    conditionType = new DataTypeDescriptor(TypeId.BOOLEAN_ID, true);
                    condition.setType(conditionType);
                }
                conditionInst = typesTranslator.typeForSQLType(conditionType);
                conditions.add(new ParameterCondition(((ParameterNode)condition)
                                                      .getParameterNumber(),
                                                      conditionType, condition, conditionInst));
                return;
            case NodeTypes.CAST_NODE:
                // Use given cast type if it's suitable for a condition.
                conditionType = condition.getType();
                // CAST inside to BOOLEAN below.
                condition = ((CastNode)condition).getCastOperand();
                break;
            case NodeTypes.JAVA_TO_SQL_VALUE_NODE:
                conditions.add((ConditionExpression)
                               toExpression(((JavaToSQLValueNode)condition).getJavaValueNode(),
                                            condition, true,
                                            projects));
                return;
            }
            // Anything else gets CAST to BOOLEAN, which may fail
            // later due to lack of a suitable cast.
            if (conditionType == null)
                conditionType = condition.getType();
            if (conditionType == null)
                conditionType = new DataTypeDescriptor(TypeId.BOOLEAN_ID, true);
            else if (!conditionType.getTypeId().isBooleanTypeId())
                conditionType = new DataTypeDescriptor(TypeId.BOOLEAN_ID, conditionType.isNullable());
            conditionInst = typesTranslator.typeForSQLType(conditionType);
            conditions.add(new BooleanCastExpression(toExpression(condition, projects),
                                                     conditionType, condition, conditionInst));
        }
View Full Code Here

                throws StandardException {
            ExpressionNode left = toExpression(between.getLeftOperand(), projects);
            ValueNodeList rightOperandList = between.getRightOperandList();
            ExpressionNode right1 = toExpression(rightOperandList.get(0), projects);
            ExpressionNode right2 = toExpression(rightOperandList.get(1), projects);
            DataTypeDescriptor sqlType = between.getType();
            TInstance type = typesTranslator.typeForSQLType(sqlType);
            conditions.add(new ComparisonCondition(Comparison.GE, left, right1, sqlType, null, type));
            conditions.add(new ComparisonCondition(Comparison.LE, left, right2, sqlType, null, type));
        }
View Full Code Here

                    flattenAnyComparisons(conds, ((RowConstructorNode)leftOperand).getNodeList(), source,
                                          projects, sqlType);
                }
                else {
                    ExpressionNode left = toExpression(leftOperand, projects);
                    DataTypeDescriptor leftType = left.getSQLtype();
                    TInstance leftInst = typesTranslator.typeForSQLType(leftType);
                    ConditionExpression cond =
                        new ComparisonCondition(Comparison.EQ,
                                                left,
                                                new ColumnExpression(source, conds.size(), leftType, null, leftInst),
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.