Views Filter on a subquery custom field I've defined a global table, like this:

  $data['custom_test']['table']['group'] = t('Custom: Test');
  $data['custom_test']['table']['join'] = array(
    // #global is a special flag which let's a table appear all the time.
    '#global' =&gt; array(),
  );


Next I added a custom field:

  $data['custom_test']['test'] = array(
    'title' =&gt; t('Test'),
    'help' =&gt; t('Show test field'),
    'field' =&gt; array(
      'handler' =&gt; 'custom_test_handler_test_field',
    ),


With this I could now make a field handler; This field handler adds a subquery:

$this-&gt;query-&gt;add_field(NULL, "(QUERY)", '(FIELD)');


And with this I can output the result. 

However, when I add a filter, (using a default filter handler), the query looks something like:

AND (.test BETWEEN '20' AND '30') ))


So what it does is that it tries to prefix a table, however there are no tables (since it's a subquery).

Is there someway I can fix this by configuration, without having to say build my own filter?
I ended up creating a filter class, since I use a subquery I needed to use HAVING rather than BETWEEN.