presto-raptor-legacy/src/main/java/io/prestosql/plugin/raptor/legacy/systemtables/ShardMetadataRecordCursor.java/ShardMetadataRecordCursor/getNextResultSet
class ShardMetadataRecordCursor:    private ResultSet getNextResultSet()
    {
        closeCurrentResultSet();

        if (!tableIds.hasNext()) {
            return null;
        }

        Long tableId = tableIds.next();
        Long columnId = metadataDao.getTemporalColumnId(tableId);
        List<String> columnNames;

        if (columnId == null) {
            columnNames = getMappedColumnNames("null", "null", "null", "null");
        }
        else {
            Type temporalType = metadataDao.getTableColumn(tableId, columnId).getDataType();
            if (temporalType.equals(DATE)) {
                columnNames = getMappedColumnNames("null", "null", minColumn(columnId), maxColumn(columnId));
            }
            else if (temporalType.equals(TIMESTAMP)) {
                columnNames = getMappedColumnNames(minColumn(columnId), maxColumn(columnId), "null", "null");
            }
            else {
                throw new PrestoException(RAPTOR_CORRUPT_METADATA, "Temporal column should be of type date or timestamp, not " + temporalType.getDisplayName());
            }
        }

        try {
            connection = dbi.open().getConnection();
            statement = PreparedStatementBuilder.create(
                    connection,
                    constructSqlTemplate(columnNames, tableId),
                    columnNames,
                    TYPES,
                    ImmutableSet.of(getColumnIndex(SHARD_METADATA, SHARD_UUID)),
                    tupleDomain);
            return statement.executeQuery();
        }
        catch (SQLException | DBIException e) {
            close();
            throw metadataError(e);
        }
    }