How can I see the query that's being run? I'm using hook_views_query_alter(), and I'd really like to print somewhere (screen, error log, whatever) the query that's being run based on the alterations. I've tried dpm($query), but that gives me the whole krumo tree - all I want is the query - i.e. "select x, y from z where a = 2". Possible?
The views_plugin_query_default class has a query() method that will take the parameters currently held in the object and provide you with a standard SelectQuery (un-executed of course).

Since the SelectQuery class implements the magic __toString() method you can then cast it directly to a string, which will be the SQL query itself:

$select_query = $query-&gt;query();
$query_string = (string)$select_query;
dpm($query_string);