Package io.crate.types

Examples of io.crate.types.DataType


    private static class Resolver implements DynamicFunctionResolver {

        @Override
        public FunctionImplementation<Function> getForTypes(List<DataType> dataTypes) throws IllegalArgumentException {
            Preconditions.checkArgument(dataTypes.size() == 2);
            DataType firstType = dataTypes.get(0);

            if (!(firstType.equals(DataTypes.GEO_POINT) ||
                    firstType.equals(DataTypes.GEO_SHAPE) ||
                    firstType.equals(DataTypes.STRING))) {
                throw new IllegalArgumentException(String.format(
                        "%s doesn't take an argument of type \"%s\" as first argument", NAME, firstType));
            }

            DataType secondType = dataTypes.get(1);
            if (!(secondType.equals(DataTypes.GEO_SHAPE) ||
                    secondType.equals(DataTypes.STRING))) {
                throw new IllegalArgumentException(String.format(
                        "%s doesn't take an argument of type \"%s\" as second argument", NAME, secondType));
            }
            return new WithinFunction(new FunctionInfo(new FunctionIdent(NAME, dataTypes), DataTypes.BOOLEAN));
        }
View Full Code Here


        if (node.innerType().type() != ColumnType.Type.PRIMITIVE) {
            throw new UnsupportedOperationException("Nesting ARRAY or SET types is not supported");
        }

        DataType innerType = process(node.innerType(), context);
        return new ArrayType(innerType);
    }
View Full Code Here

                        keyLiterals = Lists.newArrayList(currentBucket.keyParts);
                    }

                } else if (table.primaryKey().size() == 1) {
                    Set<Literal> keys = new HashSet<>();
                    DataType keyType = DataTypes.UNDEFINED;
                    for (KeyBucket bucket : buckets) {
                        Literal keyPart = bucket.keyParts[0];
                        if (keyPart != null) {
                            keyType = keyPart.valueType();
                            if (keyType.id() == SetType.ID) {
                                keys.addAll(Literal.explodeCollection(keyPart));
                            } else {
                                keys.add(keyPart);
                            }
                        }
View Full Code Here

            if (!(subQueryColumn instanceof DataTypeSymbol)) {
                throw new IllegalArgumentException(
                        SymbolFormatter.format("Invalid column expression in subquery: '%s'", subQueryColumn)
                );
            }
            DataType subQueryColumnType = ((DataTypeSymbol) subQueryColumn).valueType();

            if (subQueryColumnType != insertColumn.valueType()) {
                if (!subQueryColumnType.isConvertableTo(insertColumn.valueType())) {
                    throw new IllegalArgumentException(
                            String.format(Locale.ENGLISH,
                                    "Type of subquery column %s (%s) does not match /" +
                                            " is not convertable to the type of table column %s (%s)",
                                    SymbolFormatter.format(subQueryColumn),
View Full Code Here

     * @return dataType of the column with columnProperties
     */
    private DataType getColumnDataType(String columnName,
                                       @Nullable ColumnIdent columnIdent,
                                       Map<String, Object> columnProperties) {
        DataType type;
        String typeName = (String) columnProperties.get("type");

        if (typeName == null) {
            if (columnProperties.containsKey("properties")) {
                type = DataTypes.OBJECT;
View Full Code Here

            return;
        }

        for (Map.Entry<String, Object> columnEntry : propertiesMap.entrySet()) {
            Map<String, Object> columnProperties = (Map) columnEntry.getValue();
            DataType columnDataType = getColumnDataType(columnEntry.getKey(), columnIdent, columnProperties);
            ReferenceInfo.IndexType columnIndexType = getColumnIndexType(columnEntry.getKey(), columnProperties);
            List<String> copyToColumns = getNested(columnProperties, "copy_to");

            if (columnDataType == DataTypes.OBJECT
                    || ( columnDataType.id() == ArrayType.ID
                        && ((ArrayType)columnDataType).innerType() == DataTypes.OBJECT )) {
                ColumnPolicy columnPolicy =
                        ColumnPolicy.of(columnProperties.get("dynamic"));
                ColumnIdent newIdent = childIdent(columnIdent, columnEntry.getKey());
                add(newIdent, columnDataType, columnPolicy, ReferenceInfo.IndexType.NO, false);
View Full Code Here

    }

    private void extractPartitionedByColumns() {
        for (List<String> partitioned : partitionedByList) {
            ColumnIdent ident = ColumnIdent.fromPath(partitioned.get(0));
            DataType type = getColumnDataType(ident.fqn(),
                    ident,
                    new MapBuilder<String, Object>().put("type", partitioned.get(1)).map());
            addPartitioned(ident, type);
        }
    }
View Full Code Here

    }

    @Test
    public void testForValueWithList() {
        List<String> strings = Arrays.asList("foo", "bar");
        DataType dataType = DataTypes.guessType(strings);
        assertEquals(dataType, new ArrayType(DataTypes.STRING));

        List<Integer> integers = Arrays.asList(1, 2, 3);
        dataType = DataTypes.guessType(integers);
        assertEquals(dataType, new ArrayType(DataTypes.INTEGER));
View Full Code Here

    }

    @Test
    public void testForValueWithArray() {
        Boolean[] booleans = new Boolean[] {true, false};
        DataType dataType = DataTypes.guessType(booleans);
        assertEquals(dataType, new ArrayType(DataTypes.BOOLEAN));
    }
View Full Code Here

    }

    @Test
    public void testForValueWithTimestampArrayAsString() {
        String[] strings = {"2013-09-10T21:51:43", "2013-11-10T21:51:43"};
        DataType dataType = DataTypes.guessType(strings, false);
        assertEquals(dataType, new ArrayType(DataTypes.TIMESTAMP));
    }
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.