How to add a new join table by using a hook view?
Here is a solution to add a join table to an SQL query in views.

Let's consider a view for a Person entity. We want to add a join to a PersonTag entity. Person has an id field (the primary key);
PersonTag has a person_id field that contains the PersonTag ID.

In your module_name.module, you would add this hook_views_query_alter() implementation.

function module_name_views_query_alter($view, $query) {
  if ($view-&gt;id() == 'views_id') {  
    $definition = [
      'table' =&gt; 'person_tag_field_data',
      'field' =&gt; 'person_id',
      'left_table' =&gt; 'person_field_data',
      'left_field' =&gt; 'id',
    ];
    $join = Drupal::service('plugin.manager.views.join')-&gt;createInstance('standard', $definition);
    $query-&gt;addRelationship('person_tag_field_data', $join, 'person'); 
  }
}


After clearing the cache, you could check the SQL query used by the view and notice INNER JOIN is added to the query.

module_name is the name of your module, views_id is the ID of your view, person_tag_field_data is the table name for the PersonTag entity, and person_field_data is the table name for the Person entity.