hook_views_query_alter() not working?
Nothing changes because you are setting a hook argument, but the value to which you set that argument isn't kept.
hook_views_query_alter() is invoked from Sql::alter(), which is called from ViewsExecutable::build().
// ViewsExecutable::build()
// Let modules modify the query just prior to finalizing it.
$this-&gt;query-&gt;alter($this);

// Sql::alter()
\Drupal::moduleHandler()-&gt;invokeAll('views_query_alter', [$view, $this]);

The only way to alter the query is using the methods made available from QueryPluginBase (including its parent classes), not replacing an object passed to the hook with another object. See for example workspaces_views_query_alter(), an implementation of that hook done from a Drupal core module. The relevant code altering the query is the following one (ViewsQueryAlter::alterQuery() and ViewsQueryAlter::alterQueryForEntityType()). (I copied only the comments that could help in understanding the changes done to the query.)
public function alterQuery(ViewExecutable $view, QueryPluginBase $query) {
  if (!$this-&gt;workspaceManager-&gt;hasActiveWorkspace()) {
    return;
  }

  if (!$query instanceof Sql) {
    return;
  }

  $entity_type_ids = [];
  foreach ($query-&gt;relationships as $info) {
    $table_data = $this-&gt;viewsData-&gt;get($info['base']);
    if (empty($table_data['table']['entity type'])) {
      continue;
    }
    $entity_type_id = $table_data['table']['entity type'];

    $entity_type_ids[$entity_type_id] = $entity_type_id;
  }
  $entity_type_definitions = $this-&gt;entityTypeManager-&gt;getDefinitions();
  foreach ($entity_type_ids as $entity_type_id) {
    if ($this-&gt;workspaceManager-&gt;isEntityTypeSupported($entity_type_definitions[$entity_type_id])) {
      $this-&gt;alterQueryForEntityType($query, $entity_type_definitions[$entity_type_id]);
    }
  }
}

protected function alterQueryForEntityType(Sql $query, EntityTypeInterface $entity_type) {
  $table_mapping = $this-&gt;entityTypeManager-&gt;getStorage($entity_type-&gt;id())-&gt;getTableMapping();
  $field_storage_definitions = $this-&gt;entityFieldManager-&gt;getFieldStorageDefinitions($entity_type-&gt;id());
  $dedicated_field_storage_definitions = array_filter($field_storage_definitions, function ($definition) use ($table_mapping) {
    return $table_mapping-&gt;requiresDedicatedTableStorage($definition);
  });
  $dedicated_field_data_tables = array_map(function ($definition) use ($table_mapping) {
    return $table_mapping-&gt;getDedicatedDataTableName($definition);
  }, $dedicated_field_storage_definitions);
  $move_workspace_tables = [];
  $table_queue =&amp; $query-&gt;getTableQueue();
  foreach ($table_queue as $alias =&gt; &amp;$table_info) {
    if ($table_info['table'] == 'workspace_association') {
      break;
    }

    if ($field_name = array_search($table_info['table'], $dedicated_field_data_tables, TRUE)) {
      $relationship = $table_info['relationship'];

      if ($table_info['join']-&gt;field != 'entity_id') {
        continue;
      }

      $new_table_name = $table_mapping-&gt;getDedicatedRevisionTableName($field_storage_definitions[$field_name]);

      $workspace_association_table = $this-&gt;ensureWorkspaceAssociationTable($entity_type-&gt;id(), $query, $relationship);

      // Update the join to use our COALESCE.
      $revision_field = $entity_type-&gt;getKey('revision');
      $table_info['join']-&gt;leftFormula = &quot;COALESCE({$workspace_association_table}.target_entity_revision_id, {$relationship}.{$revision_field})&quot;;

      // Update the join and the table info to our new table name, and to join
      // on the revision key.
      $table_info['table'] = $new_table_name;
      $table_info['join']-&gt;table = $new_table_name;
      $table_info['join']-&gt;field = 'revision_id';

      // Finally, if we added the workspace_association table we have to move
      // it in the table queue so that it comes before this field.
      if (empty($move_workspace_tables[$workspace_association_table])) {
        $move_workspace_tables[$workspace_association_table] = $alias;
      }
    }
  }

  // JOINs must be in order. i.e, any tables you mention in the ON clause of a
  // JOIN must appear prior to that JOIN. Since we're modifying a JOIN in
  // place, and adding a new table, we must ensure that the new table appears
  // prior to this one. So we recorded at what index we saw that table, and
  // then use array_splice() to move the workspace_association table join to
  // the correct position.
  foreach ($move_workspace_tables as $workspace_association_table =&gt; $alias) {
    $this-&gt;moveEntityTable($query, $workspace_association_table, $alias);
  }
  $base_entity_table = $entity_type-&gt;isTranslatable() ? $entity_type-&gt;getDataTable() : $entity_type-&gt;getBaseTable();
  $base_fields = array_diff($table_mapping-&gt;getFieldNames($entity_type-&gt;getBaseTable()), [
    $entity_type-&gt;getKey('langcode'),
  ]);
  $revisionable_fields = array_diff($table_mapping-&gt;getFieldNames($entity_type-&gt;getRevisionDataTable()), $base_fields);

  // Go through and look to see if we have to modify fields and filters.
  foreach ($query-&gt;fields as &amp;$field_info) {
    // Some fields don't actually have tables, meaning they're formulae and
    // whatnot. At this time we are going to ignore those.
    if (empty($field_info['table'])) {
      continue;
    }

    // Dereference the alias into the actual table.
    $table = $table_queue[$field_info['table']]['table'];
    if ($table == $base_entity_table &amp;&amp; in_array($field_info['field'], $revisionable_fields)) {
      $relationship = $table_queue[$field_info['table']]['alias'];
      $alias = $this-&gt;ensureRevisionTable($entity_type, $query, $relationship);
      if ($alias) {
        // Change the base table to use the revision table instead.
        $field_info['table'] = $alias;
      }
    }
  }
  $relationships = [];

  // Build a list of all relationships that might be for our table.
  foreach ($query-&gt;relationships as $relationship =&gt; $info) {
    if ($info['base'] == $base_entity_table) {
      $relationships[] = $relationship;
    }
  }

  // Now we have to go through our where clauses and modify any of our fields.
  foreach ($query-&gt;where as &amp;$clauses) {
    foreach ($clauses['conditions'] as &amp;$where_info) {
      // Build a matrix of our possible relationships against fields we need
      // to switch.
      foreach ($relationships as $relationship) {
        foreach ($revisionable_fields as $field) {
          if (is_string($where_info['field']) &amp;&amp; $where_info['field'] == &quot;{$relationship}.{$field}&quot;) {
            $alias = $this-&gt;ensureRevisionTable($entity_type, $query, $relationship);
            if ($alias) {
              // Change the base table to use the revision table instead.
              $where_info['field'] = &quot;{$alias}.{$field}&quot;;
            }
          }
        }
      }
    }
  }
}

The code is also wrong because it replaces an instance of a class that extends QueryPluginBase with an instance of a class that implements StatementInterface. Those objects aren't interchangeable, as their methods and properties are different.