It’s this line: https://github.com/discourse/discourse-data-explorer/blob/705753216cc632b4f6505d2000926ab3b73d8628/lib/result_to_markdown.rb#L20
related = relations.dig(colrender[col_index].to_sym) if col_index < colrender.size
The if condition on the end is incorrect: colrender is supposed to be sparse, not packed. It will contain nulls if some but not all columns provide extra rendering data.
The correct check would probably be unless colrender[col_index].nil?
Also, this code appears to neglect the url, reltime, and html rendering types because they’re not ActiveRecord classes.