public List getColumns()

in asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBProtocolBase.java [172:202]


    public List<ADBColumn> getColumns(QueryServiceResponse response) throws SQLException {
        if (isExplainOnly(response)) {
            return Collections.singletonList(new ADBColumn(EXPLAIN_ONLY_RESULT_COLUMN_NAME, ADBDatatype.STRING, false));
        }
        QueryServiceResponse.Signature signature = response.signature;
        if (signature == null) {
            throw getErrorReporter().errorInProtocol();
        }
        List<String> nameList = signature.name;
        List<String> typeList = signature.type;
        if (nameList == null || nameList.isEmpty() || typeList == null || typeList.isEmpty()) {
            throw getErrorReporter().errorBadResultSignature();
        }
        int count = nameList.size();
        List<ADBColumn> result = new ArrayList<>(count);
        for (int i = 0; i < count; i++) {
            String columnName = nameList.get(i);
            String typeName = typeList.get(i);
            boolean optional = false;
            if (typeName.endsWith(OPTIONAL_TYPE_SUFFIX)) {
                optional = true;
                typeName = typeName.substring(0, typeName.length() - OPTIONAL_TYPE_SUFFIX.length());
            }
            ADBDatatype columnType = ADBDatatype.findByTypeName(typeName);
            if (columnType == null) {
                throw getErrorReporter().errorBadResultSignature();
            }
            result.add(new ADBColumn(columnName, columnType, optional));
        }
        return result;
    }