Package com.foundationdb.sql.types

Examples of com.foundationdb.sql.types.DataTypeDescriptor


                row(ftID, 3, 30),
                row(ftID, 4, 40));

        fromGroupRows = runPlanTxn(groupScanCreator(ftID));
        columnNames = Arrays.asList("id", "x");
        DataTypeDescriptor d = new DataTypeDescriptor(TypeId.INTEGER_ID, false);
        fromDescriptors = Arrays.asList(d, d);
        server = new TestSession();
    }
View Full Code Here


            columnNames[i] = columns.get(i).getName();
            columnTypes[i] = columns.get(i).getType().dataTypeDescriptor();
        }
        TypeId typeId = new TypeId.RowMultiSetTypeId(columnNames, columnTypes);
        Boolean isNullable = type.nullability();
        return new DataTypeDescriptor(typeId, isNullable);
    }
View Full Code Here

    protected DataTypeDescriptor dataTypeDescriptor(TInstance type) {
        Boolean isNullable = type.nullability(); // on separate line to make NPE easier to catch
        int literalFormatId = type.attribute(formatAttribute);
        IntervalFormat format = formatters[literalFormatId];
        TypeId typeId = format.getTypeId();
        return new DataTypeDescriptor(typeId, isNullable);
    }
View Full Code Here

        currentSelectNode.getFromList().addAll(selectNode.getFromList());
        currentSelectNode.setWhereClause(mergeWhereClause(currentSelectNode.getWhereClause(),
                                                          selectNode.getWhereClause()));
        if (leftOperand == null) {
            ValueNode node = (ValueNode)nodeFactory.getNode(NodeTypes.BOOLEAN_CONSTANT_NODE, Boolean.TRUE, parserContext);
            node.setType(new DataTypeDescriptor(TypeId.BOOLEAN_ID, false));
            return node;
        }

        int nodeType = 0;
        if (parentComparisonOperator != null)
            nodeType = parentComparisonOperator.getNodeType();
        else {
            switch (subqueryNode.getSubqueryType()) {
                // TODO: The ALL and NOT_IN cases aren't actually supported here yet.
            case IN:
            case EQ_ANY:
            case NOT_IN:
            case NE_ALL:
                nodeType = NodeTypes.BINARY_EQUALS_OPERATOR_NODE;
                break;

            case NE_ANY:
            case EQ_ALL:
                nodeType = NodeTypes.BINARY_NOT_EQUALS_OPERATOR_NODE;
                break;

            case LE_ANY:
            case GT_ALL:
                nodeType = NodeTypes.BINARY_LESS_EQUALS_OPERATOR_NODE;
                break;

            case LT_ANY:
            case GE_ALL:
                nodeType = NodeTypes.BINARY_LESS_THAN_OPERATOR_NODE;
                break;

            case GE_ANY:
            case LT_ALL:
                nodeType = NodeTypes.BINARY_GREATER_EQUALS_OPERATOR_NODE;
                break;

            case GT_ANY:
            case LE_ALL:
                nodeType = NodeTypes.BINARY_GREATER_THAN_OPERATOR_NODE;
                break;

            default:
                assert false;
            }
        }
        // when multiple columns in the leftOperand
        if (leftOperand instanceof RowConstructorNode) {
            RowConstructorNode rcn = (RowConstructorNode)leftOperand;
            if (rcn.listSize() != selectNode.getResultColumns().size()) {
                throw new UnsupportedSQLException("Subquery needs equal number of columns on left and right side of ... IN ... clause ");
            }
            ResultColumnList rcl = selectNode.getResultColumns();
            ValueNode leftO = null, rightO = null;
            // create branch of equivalent relations for the different columns, connected by AndNodes, and ending with a True Node
            for (int i = rcn.listSize()-1; i >= 0; i--) {
                if (i == rcn.listSize() - 1 ) {
                    rightO = (ValueNode)nodeFactory.getNode(NodeTypes.BOOLEAN_CONSTANT_NODE, Boolean.TRUE, parserContext);
                    rightO.setType(new DataTypeDescriptor(TypeId.BOOLEAN_ID, false));
                }
                else {
                    rightO = (ValueNode)nodeFactory.getNode(NodeTypes.AND_NODE, leftO, rightO, parserContext);
                    rightO.setType(new DataTypeDescriptor(TypeId.BOOLEAN_ID, false));
                }
                leftO = (ValueNode)nodeFactory.getNode(NodeTypes.BINARY_EQUALS_OPERATOR_NODE, rcn.getNodeList().get(i), rcl.get(i).getExpression(), parserContext);
                leftO.setType(new DataTypeDescriptor(TypeId.BOOLEAN_ID, false));
            }
            leftOperand = leftO;
            rightOperand = rightO;
            nodeType = NodeTypes.AND_NODE;
        }
  
        ValueNode newNode = (ValueNode)nodeFactory.getNode(nodeType, leftOperand, rightOperand, parserContext);
        newNode.setType(new DataTypeDescriptor(TypeId.BOOLEAN_ID, false));
        return newNode;
    }
View Full Code Here

        AISBuilder builder = new AISBuilder();
        builder.view(schemaName, viewName, viewdef.getQueryExpression(),
                     binderContext.getParserProperties(schemaName), tableColumnReferences);
        int colpos = 0;
        for (ResultColumn rc : viewdef.getResultColumns()) {
            DataTypeDescriptor type = rc.getType();
            if (type == null) {
                if (rc.getExpression().getNodeType() != NodeTypes.UNTYPED_NULL_CONSTANT_NODE)
                    throw new AkibanInternalException(rc.getName() + " has unknown type");
                type = new DataTypeDescriptor(TypeId.CHAR_ID, true, 0);
            }
            TableDDL.addColumn(builder, typesTranslator,
                               schemaName, viewName, rc.getName(), colpos++,
                               type, null, null);
        }
View Full Code Here

                ExpressionNode operand = expr.getOperand();
                List<ExpressionNode> noperands = new ArrayList<>(2);
                noperands.add(new AggregateFunctionExpression("SUM", operand, expr.isDistinct(),
                                                              operand.getSQLtype(), null,
                                                              operand.getType(), null, null));
                DataTypeDescriptor intType = new DataTypeDescriptor(TypeId.INTEGER_ID, false);
                TInstance intInst = rulesContext.getTypesTranslator().typeForSQLType(intType);
                noperands.add(new AggregateFunctionExpression("COUNT", operand, expr.isDistinct(),
                                                              intType, null, intInst, null, null));
                return new FunctionExpression("divide",
                                              noperands,
                                              expr.getSQLtype(), expr.getSQLsource(), expr.getType());
            }
            if ("VAR_POP".equals(function) ||
                "VAR_SAMP".equals(function) ||
                "STDDEV_POP".equals(function) ||
                "STDDEV_SAMP".equals(function)) {
                ExpressionNode operand = expr.getOperand();
                List<ExpressionNode> noperands = new ArrayList<>(3);
                noperands.add(new AggregateFunctionExpression("_VAR_SUM_2", operand, expr.isDistinct(),
                                                              operand.getSQLtype(), null,
                                                              operand.getType(), null, null));
                noperands.add(new AggregateFunctionExpression("_VAR_SUM", operand, expr.isDistinct(),
                                                              operand.getSQLtype(), null,
                                                              operand.getType(), null, null));
                DataTypeDescriptor intType = new DataTypeDescriptor(TypeId.INTEGER_ID, false);
                TInstance intInst = rulesContext.getTypesTranslator().typeForSQLType(intType);
                noperands.add(new AggregateFunctionExpression("COUNT", operand, expr.isDistinct(),
                                                              intType, null, intInst, null, null));
                return new FunctionExpression("_" + function,
                                              noperands,
View Full Code Here

    protected void outputResultSet(ResultSet resultSet, AkibanAppender appender) throws IOException, SQLException {
        ResultSetMetaData metaData = resultSet.getMetaData();
        int ncols = metaData.getColumnCount();
        PostgresType[] pgTypes = new PostgresType[ncols];
        for (int i = 0; i < ncols; i++) {
            DataTypeDescriptor sqlType = resultColumnSQLType(metaData, i+1);
            pgTypes[i] = PostgresType.fromDerby(sqlType, null);
        }
        encoder.appendString("[");
        boolean first = true;
        while (resultSet.next()) {
View Full Code Here

        encoder.appendString("{\"name\":\"");
        Quote.DOUBLE_QUOTE.append(appender, name);
        encoder.appendString("\",columns:[");
        int ncols = metaData.getColumnCount();
        for (int i = 0; i < ncols; i++) {
            DataTypeDescriptor sqlType = resultColumnSQLType(metaData, i+1);
            PostgresType pgType = PostgresType.fromDerby(sqlType, null);

            if (i > 0)
                encoder.appendString(",");
            encoder.appendString("{\"name\":\"");
            Quote.DOUBLE_QUOTE.append(appender, metaData.getColumnName(i+1));
            encoder.appendString("\"");
            encoder.appendString(",\"oid\":");
            encoder.getWriter().print(pgType.getOid());
            encoder.appendString(",\"type\":\"");
            Quote.DOUBLE_QUOTE.append(appender, sqlType.toString());
            encoder.appendString("\"");
            if (sqlType.getTypeId().isDecimalTypeId()) {
                encoder.appendString(",\"precision\":");
                encoder.getWriter().print(sqlType.getPrecision());
                encoder.appendString(",\"scale\":");
                encoder.getWriter().print(sqlType.getScale());
            }
            else if (sqlType.getTypeId().variableLength()) {
                encoder.appendString(",\"length\":");
                encoder.getWriter().print(sqlType.getMaximumWidth());
            }
            encoder.appendString("}");
        }
        encoder.appendString("]}");
    }
View Full Code Here

            catch (StandardException ex) {
                throw new SQLParserInternalException(ex);
            }
        }
        if (typeId.isDecimalTypeId()) {
            return new DataTypeDescriptor(typeId,
                                          metaData.getPrecision(i),
                                          metaData.getScale(i),
                                          metaData.isNullable(i) != ResultSetMetaData.columnNoNulls,
                                          metaData.getColumnDisplaySize(i));
            }
        else {
            return new DataTypeDescriptor(typeId,
                                          metaData.isNullable(i) != ResultSetMetaData.columnNoNulls,
                                          metaData.getColumnDisplaySize(i));
        }
    }
View Full Code Here

                    condition = entry.get(--size);
                    boolean nullable = isNullable(condition);
                    while (size > 0) {
                        ConditionExpression left = entry.get(--size);
                        nullable |= isNullable(left);
                        DataTypeDescriptor sqlType = new DataTypeDescriptor (TypeId.BOOLEAN_ID, nullable);
                        TInstance type = rulesContext.getTypesTranslator().typeForSQLType(sqlType);
                        condition = new BooleanOperationExpression(Operation.AND,
                                                                   left,
                                                                   condition,
                                                                   sqlType,
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.