Yiisoft\Db\Query\Query class can be extended in each supported DBMS.
E.g. we can have Yiisoft\Db\Mssql\Query which extends Yiisoft\Db\Query\Query.
In this case ActiveQuery will not know about the extensions in Yiisoft\Db\Mssql\Query.
Suggestion
Connection of DBMS should return concrete Query instance to use it in ActiveQuery.