Package io.crate.types

Examples of io.crate.types.DataType


        objB.put("b", objBNested);
        objBNested.put("bn1", 1);
        objBNested.put("bn2", 2);

        List<Object> objects = Arrays.<Object>asList(objA, objB);
        DataType dataType = DataTypes.guessType(objects);
        assertEquals(dataType, new ArrayType(DataTypes.OBJECT));
    }
View Full Code Here


        assertEquals(dataType, new ArrayType(DataTypes.OBJECT));
    }

    @Test
    public void testForValueWithArrayWithNullValues() {
        DataType dataType = DataTypes.guessType(new String[]{"foo", null, "bar"});
        assertEquals(dataType, new ArrayType(DataTypes.STRING));
    }
View Full Code Here

    }

    @Test
    public void testForValueWithEmptyList() {
        List<Object> objects = Arrays.<Object>asList();
        DataType type = DataTypes.guessType(objects);
        assertEquals(type, new ArrayType(DataTypes.UNDEFINED));
    }
View Full Code Here

        // 1. evaluate
        // guess type for dynamic column
        if (reference instanceof DynamicReference) {
            assert parameterOrLiteral instanceof Input;
            Object value = ((Input<?>)parameterOrLiteral).value();
            DataType guessed = DataTypes.guessType(value,
                    reference.info().columnPolicy() == ColumnPolicy.IGNORED);
            ((DynamicReference) reference).valueType(guessed);
        }

        try {
View Full Code Here

                TableInfo tableInfo = table;
                if (info.ident().tableIdent() != table.ident()) {
                    tableInfo = referenceInfos.getTableInfo(info.ident().tableIdent());
                }
                DynamicReference dynamicReference = tableInfo.getDynamic(nestedIdent, forWrite);
                DataType type = DataTypes.guessType(entry.getValue(), false);
                if (type == null) {
                    throw new ColumnValidationException(info.ident().columnIdent().fqn(), "Invalid value");
                }
                dynamicReference.valueType(type);
                nestedInfo = dynamicReference.info();
View Full Code Here

                    throw new IllegalArgumentException("mixed number of arguments inside bulk arguments");
                }

                for (int i = 0; i < bulkParam.length; i++) {
                    Object o = bulkParam[i];
                    DataType expectedType = bulkTypes[i];
                    DataType guessedType = guessTypeSafe(o);

                    if (expectedType == DataTypes.UNDEFINED) {
                        bulkTypes[i] = guessedType;
                    } else if (o != null && !bulkTypes[i].equals(guessedType)) {
                        throw new IllegalArgumentException(String.format(Locale.ENGLISH,
View Full Code Here

                }
            }
        }

        private static DataType guessTypeSafe(Object value) throws IllegalArgumentException {
            DataType guessedType = DataTypes.guessType(value);
            if (guessedType == null) {
                throw new IllegalArgumentException(String.format(
                        "Got an argument \"%s\" that couldn't be recognized", value));
            }
            return guessedType;
View Full Code Here

    }

    private static DataType resolveType(List<Projection> projections, int projectionIdx, int columnIdx, List<DataType> inputTypes) {
        Projection projection = projections.get(projectionIdx);
        Symbol symbol = projection.outputs().get(columnIdx);
        DataType type = DataTypeVisitor.fromSymbol(symbol);
        if (type == null || (type.equals(DataTypes.UNDEFINED) && symbol instanceof InputColumn)) {
            if (projectionIdx > 0) {
                if (symbol instanceof InputColumn) {
                    columnIdx = ((InputColumn) symbol).index();
                }
                return resolveType(projections, projectionIdx - 1, columnIdx, inputTypes);
View Full Code Here

TOP

Related Classes of io.crate.types.DataType

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.