private void validateType()

in cassandra-four-zero-types/src/main/java/org/apache/cassandra/spark/reader/SchemaBuilder.java [239:297]


    private void validateType(CQL3Type cqlType)
    {
        if (!(cqlType instanceof CQL3Type.Native)
                && !(cqlType instanceof CQL3Type.Collection)
                && !(cqlType instanceof CQL3Type.UserDefined)
                && !(cqlType instanceof CQL3Type.Tuple))
        {
            throw new UnsupportedOperationException("Only native, collection, tuples or UDT data types are supported, "
                                                  + "unsupported data type: " + cqlType.toString());
        }

        if (cqlType instanceof CQL3Type.Native)
        {
            CqlField.CqlType type = cassandraTypes.parseType(cqlType.toString());
            if (!type.isSupported())
            {
                throw new UnsupportedOperationException(type.name() + " data type is not supported");
            }
        }
        else if (cqlType instanceof CQL3Type.Collection)
        {
            // Validate collection inner types
            CQL3Type.Collection collection = (CQL3Type.Collection) cqlType;
            CollectionType<?> type = (CollectionType<?>) collection.getType();
            switch (type.kind)
            {
                case LIST:
                    validateType(((ListType<?>) type).getElementsType());
                    return;
                case SET:
                    validateType(((SetType<?>) type).getElementsType());
                    return;
                case MAP:
                    validateType(((MapType<?, ?>) type).getKeysType());
                    validateType(((MapType<?, ?>) type).getValuesType());
                    return;
                default:
                    // Do nothing
            }
        }
        else if (cqlType instanceof CQL3Type.Tuple)
        {
            CQL3Type.Tuple tuple = (CQL3Type.Tuple) cqlType;
            TupleType tupleType = (TupleType) tuple.getType();
            for (AbstractType<?> subType : tupleType.allTypes())
            {
                validateType(subType);
            }
        }
        else
        {
            // Validate UDT inner types
            UserType userType = (UserType) ((CQL3Type.UserDefined) cqlType).getType();
            for (AbstractType<?> innerType : userType.fieldTypes())
            {
                validateType(innerType);
            }
        }
    }