Getting rid of unwanted nonSQL syntax characters when debugging a query

what you are getting is a sql statement not a sql query result.

actually die is a function so should be die();
when using

print_r($query); die();
$rows = $wpdb->get_results($query);

the second line will just not be used, so no results will be display from the query, this said, $query is a php variable that will be the sql query, but could have any other name like for example $myQuery. this said, the output you are getting is the query(sql statement) that will be used in the second line when you comment the first line. so unless in your database you have all that @r, the query to your database will not get any result, will return an error of sintaxe. this means, and like I am understanding the @r are not the intended rows names of your table. the issue comes from behind, from where your variable $query is being created.
here’s an example that will demonstrate what I am saying.
put this code before those lines you have share with us

$myQuery = 'show tables';
$rows = $wpdb->get_results($myQuery);
echo '<pre>';
print_r($rows);
echo '</pre>';
die();

this will return all tables names, if you use only your code without the first line, you will receive possibly an sintaxe error. if this happens, the issue is on your variable $query, on how the variable is being created.