Package com.foundationdb.server.types

Examples of com.foundationdb.server.types.TInstance


            return boolExpr(expression, nullable);
        }

        private boolean isNullable(ExpressionNode node) {
            TInstance type = type(node);
            return type == null || type.nullability();
        }
View Full Code Here


        ExpressionNode handleColumnExpression(ColumnExpression expression) {
            Column column = expression.getColumn();
            ColumnSource columnSource = expression.getTable();
            if (column != null) {
                assert columnSource instanceof TableSource : columnSource;
                TInstance columnInstance = column.getType();
                if ((Boolean.FALSE == columnInstance.nullability()) &&
                    (expression.getSQLtype() != null) &&
                    (expression.getSQLtype().isNullable())) {
                    // With an outer join, the column can still be nullable.
                    columnInstance = columnInstance.withNullable(true);
                }
                expression.setPreptimeValue(new TPreptimeValue(columnInstance));
            }
            else if (columnSource instanceof AggregateSource) {
                AggregateSource aggTable = (AggregateSource) columnSource;
                TPreptimeValue ptv = aggTable.getField(expression.getPosition()).getPreptimeValue();
                expression.setPreptimeValue(ptv);
            }
            else if (columnSource instanceof SubquerySource) {
                TPreptimeValue tpv;
                Subquery subquery = ((SubquerySource)columnSource).getSubquery();
                TypedPlan typedSubquery = findTypedPlanNode(subquery.getInput());
                if (typedSubquery != null) {
                    tpv = new TPreptimeValue(typedSubquery.getTypeAt(expression.getPosition()));
                }
                else {
                    logger.warn("no Project found for subquery: {}", columnSource);
                    tpv = new TPreptimeValue(typesTranslator.typeForSQLType(expression.getSQLtype()));
                }
                expression.setPreptimeValue(tpv);
                return expression;
            }
            else if (columnSource instanceof NullSource) {
                expression.setPreptimeValue(new TPreptimeValue(null, null));
                return expression;
            }
            else if (columnSource instanceof Project) {
                Project pTable = (Project) columnSource;
                TPreptimeValue ptv = pTable.getFields().get(expression.getPosition()).getPreptimeValue();
                expression.setPreptimeValue(ptv);
            }
            else if (columnSource instanceof ExpressionsSource) {
                ExpressionsSource exprsTable = (ExpressionsSource) columnSource;
                List<List<ExpressionNode>> expressions = exprsTable.getExpressions();
                TPreptimeValue tpv;
                if (expressions.size() == 1) {
                    // get the TPV straight from the expression, since there's just one row
                    tpv = expressions.get(0).get(expression.getPosition()).getPreptimeValue();
                }
                else {
                    TInstance type = exprsTable.getTypeAt(expression.getPosition());
                    tpv = new TPreptimeValue(type);
                }
                expression.setPreptimeValue(tpv);
            }
            else if (columnSource instanceof CreateAs){
View Full Code Here

            return boolExpr(expression, nullable);
        }

        ExpressionNode handleParameterCondition(ParameterCondition expression) {
            parametersSync.uninferred(expression);
            TInstance type = AkBool.INSTANCE.instance(true);
            return castTo(expression, type,
                          folder, parametersSync);
        }
View Full Code Here

                        projectType = leftType.getDominantType(rightType);
                    } catch (StandardException e) {
                        projectType = null;
                    }
                }
                TInstance projectInst = typesTranslator.typeForSQLType(projectType);

                leftProject.applyCast(i, projectType, projectInst);
                rightProject.applyCast(i, projectType, projectInst);

                ResultField leftField = leftResult.getFields().get(i);
View Full Code Here

        }


        private void castProjectField (CastExpression cast, Folder folder, ParametersSync parameterSync, TypesTranslator typesTranslator) {
            DataTypeDescriptor dtd = cast.getSQLtype();
            TInstance type = typesTranslator.typeForSQLType(dtd);
            cast.setPreptimeValue(new TPreptimeValue(type));
            TypeResolver.finishCast(cast, folder, parameterSync);
        }
View Full Code Here

        if ((sequence != null) && Boolean.FALSE.equals(column.getDefaultIdentity())) {
            // FALSE => ALWAYS, override user value even if present
            expression = new TSequenceNextValueExpression(column.getType(), sequence);
        }
        else if (expression == null) {
            TInstance type = column.getType();
            if (sequence != null) {
                expression = new TSequenceNextValueExpression(type, sequence);
            }
            else if (column.getDefaultFunction() != null) {
                OverloadResolver<TValidatedScalar> resolver = typesService.getScalarsResolver();
                TValidatedScalar overload = resolver.get(column.getDefaultFunction(),
                                                         Collections.<TPreptimeValue>emptyList()).getOverload();
                TInstance dinst = overload.resultStrategy().fixed(false);
                TPreparedExpression defExpr = new TPreparedFunction(overload,
                                                                    dinst,
                                                                    Collections.<TPreparedExpression>emptyList());
                if (!dinst.equals(type)) {
                    TCast tcast = typesService.getCastsResolver().cast(dinst.typeClass(), type.typeClass());
                    defExpr = new TCastExpression(defExpr, tcast, type);
                }
                expression = defExpr;
            }
            else {
                final String defaultValue = column.getDefaultValue();
                final Value defaultValueSource;
                if(defaultValue == null) {
                    defaultValueSource = new Value(type);
                    defaultValueSource.putNull();
                } else {
                    TCast cast = type.typeClass().castFromVarchar();
                    if (cast != null) {
                        defaultValueSource = new Value(type);
                        TInstance valInst = typesTranslator.typeForString(defaultValue);
                        TExecutionContext executionContext = new TExecutionContext(Collections.singletonList(valInst),
                                                                                   type,
                                                                                   queryContext);
                        cast.evaluate(executionContext,
                                      new Value(valInst, defaultValue),
View Full Code Here

            keyPTarget.putNull();
            return true;
        }
        if (value == null)
            return false;
        TInstance type;
        determine_type:
        {
            if (index.isSpatial()) {
                int firstSpatialColumn = index.firstSpatialArgument();
                if (column == firstSpatialColumn) {
                    type = InternalIndexTypes.LONG.instance(node.getPreptimeValue().isNullable());
                    break determine_type;
                }
                else if (column > firstSpatialColumn) {
                    column += index.dimensions() - 1;
                }
            }
            type = index.getAllColumns().get(column).getColumn().getType();
        }
        type.writeCollating(value, keyPTarget);
        return true;
    }
View Full Code Here

                return false;
           
            ValueSource leftSource = leftNode.getPreptimeValue().value();
            ValueSource rightSource = rightNode.getPreptimeValue().value();

            TInstance lTIns = leftSource.getType();
            TInstance rTIns = rightSource.getType();
           
            if (TClass.comparisonNeedsCasting(lTIns, rTIns))
            {
                boolean nullable = leftSource.isNull() || rightSource.isNull();
                TCastResolver casts = registry.getCastsResolver();
                TInstance common = TypeResolver.commonInstance(casts, lTIns, rTIns);
                if (common == null)
                    common = typesTranslator.typeForString();
               
                Value leftCasted = new Value(common);
                Value rightCasted = new Value(common);
View Full Code Here

        List<ExpressionNode> expressions = new ArrayList<>(values.getExpressions().size());
        for (List<ExpressionNode> row : values.getExpressions()) {
            expressions.add(row.get(0));
        }
        DataTypeDescriptor sqlType = new DataTypeDescriptor(TypeId.BOOLEAN_ID, true);
        TInstance type = rulesContext.getTypesTranslator().typeForSQLType(sqlType);
        InListCondition cond = new InListCondition(ccond.getLeft(), expressions,
                                                   sqlType, null, type);
        cond.setComparison(ccond);
        //cond.setPreptimeValue(new TPreptimeValue(AkBool.INSTANCE.instance(true)));
        return cond;
View Full Code Here

        ExpressionNode op4 = operands.get(3);
        if ((right.getType() != null) &&
            (right.getType().typeClass().jdbcType() != Types.DECIMAL)) {
            DataTypeDescriptor sqlType =
                new DataTypeDescriptor(TypeId.DECIMAL_ID, 10, 6, true, 12);
            TInstance type = queryGoal.getRulesContext()
                .getTypesTranslator().typeForSQLType(sqlType);
            right = new CastExpression(right, sqlType, right.getSQLsource(), type);
        }
        if (columnMatches(col1, op1) && columnMatches(col2, op2) &&
            constantOrBound(op3) && constantOrBound(op4)) {
View Full Code Here

TOP

Related Classes of com.foundationdb.server.types.TInstance

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.