Show all tags for a views query? I am trying to write a views_query_alter hook and I want to identify the query I'm interested in. I have found the methods hasTag(), hasAllTags(), and hasAnyTag(), but I don't already know which tags I'm looking for. How can I get Drupal to tell me what tags already exist on queries? I didn't see any getTags() method.
I believe you mean hook_query_alter() here by mentioning hasTag(), hasAllTags(), and hasAnyTag() not hook_views_query_alter().

You can understand more about these methods from this documentation.

By help of these methods you can specify the targeted query, when you apply this in your module. A example code has been given in answer at Stackoverflow question, which helped me long ago to modify a query of views.

function MY_MODULE_query_alter(QueryAlterableInterface $query) {
  if ($query-&gt;hasAllTags('views', '[MY VIEW NAME]')) {
    $query-&gt;addJoin('INNER', 'taxonomy_index', 'ti', 'node.nid = ti.nid');
    $query-&gt;condition('ti.tid', '2,3', 'IN');
  }
}


If you are looking for the tags which you can use, just try to print $query inside the hook &amp; see the result on the page where you are working. You will get what query you can target &amp; the tags which you can use.

I hope it helps :)