private void typeCheck()

in asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBResultSet.java [262:290]


    private void typeCheck(ADBColumn column, ADBDatatype parsedType) throws SQLException {
        ADBDatatype columnType = column.getType();

        boolean typeMatch;
        switch (parsedType) {
            case NULL:
                typeMatch = column.isOptional();
                break;
            case STRING:
                // special handling for parsed 'string' because it can contain any primitive type.
                // we only need to check that the expected type is not derived (i.e primitive/null/missing/any)
                typeMatch = !columnType.isDerived();
                break;
            case ARRAY:
                typeMatch = columnType == ADBDatatype.ANY || columnType.isList();
                break;
            case BOOLEAN:
            case BIGINT:
            case OBJECT:
                typeMatch = columnType == ADBDatatype.ANY || columnType == parsedType;
                break;
            default:
                // unexpected
                throw getErrorReporter().errorInProtocol(parsedType.toString());
        }
        if (!typeMatch) {
            throw getErrorReporter().errorUnexpectedColumnValue(parsedType, column.getName());
        }
    }