How to create a view filter plugin to filter a column created by a view field plugin I have created a view field plugin to display an &quot;internal status&quot; for each node in a view.
Those status are not stored in a table (and should not) because each status may vary depending the current date (and some other fluctuating data).
The possible status outputted by this virtual field (not sure it is the correct terminology) are 1,2 or 3 (integer)
Here is the simplified code
1-Declare the virtual field in hook_views_data_alter()
function mymodule_views_data_alter(array &amp;$data) {
  $data['node']['internal_status'] = [
    'title' =&gt; t('Internal Status'),
    'field' =&gt; [
      'title' =&gt; t('Internal Status'),
      'help' =&gt; t(&quot;Display internal status&quot;),
      'id' =&gt; 'internal_status',
    ],
  ];
}

2- Create the view plugin
/**
 * Field handler to display internal status.
 *
 * @ViewsField(&quot;internal_status&quot;)
 */
class NodeInternalStatus extends FieldPluginBase {

  public function query() {}

  public function render(ResultRow $values) {
    $node = $values-&gt;_entity;
    $value= return_1_2_or_3_depending_on_dyn_data_like_the_current_date($node);
    switch ($value){
      case 1:
        return t('This is 1');
      case 2:
        return t('This is 2');
      case 3:
        return t('This is 3');
    }
    //will never go here if everything is ok
    return t('n/a');
  }
}

My Question: I would like to create a filter plugin to filter nodes according their internal status [by using return_1_2_or_3_depending_on_dyn_data_like_the_current_date($node)]
I have tried to extend the inOperator class but as the real column of the &quot;internal status&quot; field doesn't exists in the DB, I keep getting the following error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'node_field_data.internal_status' in 'where clause':
After some digging I will answer myself to this question: it is not possible to create a filter on a non existent DB column.
How to solve this issue:
In my example, the values of this non existent column are calculated via the function return_1_2_or_3_depending_on_dyn_data_like_the_current_date($node).
We couldn't use this function to create the filter. Instead, for each value returned by the function (in my case 1,2 or 3), we have to write a query with the same logic used in the &quot;dropped&quot; function.
All the logic must reside in the query method of the filter plugin.
Here is an example:
1- Add the filter in hook_views_data_alter
function mymodule_views_data_alter(array &amp;$data) {
  $data['node_field_data']['internal_status_filter'] = [
    'title' =&gt; t('Filter by Internal Status'),
    'filter' =&gt; [
      'title' =&gt; t('Filter by Internal Status'),
      'help' =&gt; t('Bla bla'),
      'id' =&gt; 'internal_status_filter',
    ],
  ];
}

2-Create the filter plugin (In my case, I have extended the inOperator Class)
/**
 * Filters the internal status of a node
 *
 * @ingroup views_filter_handlers
 *
 * @ViewsFilter(&quot;internal_status_filter&quot;)
 */
class InternalStatus extends InOperator {

  public function init(ViewExecutable $view, DisplayPluginBase $display, array &amp;$options = NULL) {
    parent::init($view, $display, $options);
    $this-&gt;valueTitle = t('Available Status');
    $this-&gt;definition['options callback'] = array($this, 'generateOptions');
  }

  public function query() {
    $configuration = [
      'left_table' =&gt; 'node_field_data',
      'left_field' =&gt; 'nid',
      'field'      =&gt; 'entity_id',
      'type'       =&gt; 'LEFT',
      'extra_operator'   =&gt; 'AND',
    ];
    if (
    $selected_status = $this-&gt;value[0];
    if ($this-&gt;operator == 'in') {
      $this-&gt;ensureMyTable();
      switch ($selected_status) {
        case (1):
          //Add a condition on another field
          $table_field='node__field_another_field';
          $configuration['table']=$table_field;
          $join = Views::pluginManager('join')-&gt;createInstance('standard', $configuration);
          $this-&gt;query-&gt;addRelationship($table_field, $join, 'node_field_data');
          $this-&gt;query-&gt;addWhere('AND', &quot;${table_field}.field_simulation_is_past_value&quot;, 1, '=');
          //Add as many condition to get what you need
          break;
          ....
       }
     }
  }

  public function generateOptions() {
    return [
      1=&gt;'Status 1',
      2=&gt;'Status 2',
      3=&gt;'Status 3',
    ];
  }

Make sure that your annotation at the top of the file @ViewsFilter(&quot;internal_status_filter&quot;) is the same id than the ones defined in hook_views_data_alter