public static void validateIndexFieldType()

in asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/ValidateUtil.java [259:354]


    public static void validateIndexFieldType(IndexType indexType, IAType fieldType, List<String> displayFieldName,
            SourceLocation sourceLoc) throws AlgebricksException {
        switch (indexType) {
            case ARRAY:
            case BTREE:
                switch (fieldType.getTypeTag()) {
                    case TINYINT:
                    case SMALLINT:
                    case INTEGER:
                    case BIGINT:
                    case FLOAT:
                    case DOUBLE:
                    case STRING:
                    case BINARY:
                    case DATE:
                    case TIME:
                    case DATETIME:
                    case UUID:
                    case YEARMONTHDURATION:
                    case DAYTIMEDURATION:
                    case ANY:
                        break;
                    default:
                        throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
                                "The field '"
                                        + LogRedactionUtil.userData(RecordUtil.toFullyQualifiedName(displayFieldName))
                                        + "' which is of type " + fieldType.getTypeTag()
                                        + " cannot be indexed using the BTree index.");
                }
                break;
            case RTREE:
                switch (fieldType.getTypeTag()) {
                    case POINT:
                    case LINE:
                    case RECTANGLE:
                    case CIRCLE:
                    case POLYGON:
                    case GEOMETRY:
                        break;
                    default:
                        throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
                                "The field '"
                                        + LogRedactionUtil.userData(RecordUtil.toFullyQualifiedName(displayFieldName))
                                        + "' which is of type " + fieldType.getTypeTag()
                                        + " cannot be indexed using the RTree index.");
                }
                break;
            case LENGTH_PARTITIONED_NGRAM_INVIX:
                if (fieldType.getTypeTag() != ATypeTag.STRING) {
                    throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
                            "The field '" + LogRedactionUtil.userData(RecordUtil.toFullyQualifiedName(displayFieldName))
                                    + "' which is of type " + fieldType.getTypeTag()
                                    + " cannot be indexed using the Length Partitioned N-Gram index.");
                }
                break;
            case LENGTH_PARTITIONED_WORD_INVIX:
                switch (fieldType.getTypeTag()) {
                    case STRING:
                    case MULTISET:
                    case ARRAY:
                        break;
                    default:
                        throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
                                "The field '"
                                        + LogRedactionUtil.userData(RecordUtil.toFullyQualifiedName(displayFieldName))
                                        + "' which is of type " + fieldType.getTypeTag()
                                        + " cannot be indexed using the Length Partitioned Keyword index.");
                }
                break;
            case SINGLE_PARTITION_NGRAM_INVIX:
                if (fieldType.getTypeTag() != ATypeTag.STRING) {
                    throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
                            "The field '" + LogRedactionUtil.userData(RecordUtil.toFullyQualifiedName(displayFieldName))
                                    + "' which is of type " + fieldType.getTypeTag()
                                    + " cannot be indexed using the N-Gram index.");
                }
                break;
            case SINGLE_PARTITION_WORD_INVIX:
                switch (fieldType.getTypeTag()) {
                    case STRING:
                    case MULTISET:
                    case ARRAY:
                        break;
                    default:
                        throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
                                "The field '"
                                        + LogRedactionUtil.userData(RecordUtil.toFullyQualifiedName(displayFieldName))
                                        + "' which is of type " + fieldType.getTypeTag()
                                        + " cannot be indexed using the Keyword index.");
                }
                break;
            default:
                throw new CompilationException(ErrorCode.COMPILATION_UNKNOWN_INDEX_TYPE, sourceLoc,
                        String.valueOf(indexType));
        }
    }