You're right.
The conn_type is used to determine which hook to use as an interface to an external data source / sink.
conn_type is either extracted from the URI as you've specified correctly above, or from a connection created in the UI (and stored in the connection table in the Meta DB).
In your case, the conn_type is extracted from the supplied URL using the parse_from_uri method in models.py, which sets the conn_type from the scheme returned by the urlparse method.
https://github.com/apache/incubator-airflow/blob/master/airflow/models.py
According to https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse the scheme is extracted from the first part of the URI.
And as you found, the urlparse method doesn't return a scheme when there's an underscore in the url before the ://.
e.g. verify this, try variations on this URI with and without the underscore:
from urllib.parse import urlparse
[print(v) for v in urlparse("hive_cli://hiveserver/default")]
It works slightly differently if you use beeline, as it will create a JDBC connection, but if you're not using beeline (I can see you aren't because it would be part of the --conn_extra in the command) then it runs a subprocess.
Following the code, ultimately the hive_cli type is run as a subprocess.Popen, i.e. directly on the airflow machine ( or worker), not via JDBC or some other connection.
https://github.com/apache/incubator-airflow/blob/master/airflow/hooks/hive_hooks.py#L208
So therefore it doesn't really need a URL-type connection string, it's just using that format to shoe-horn into the airflow connections --con-uri option. Since it doesn't get pieced back together as a URL, then the choice to call it hive_cli appears arbitrary, and doesn't work from the airflow cli. This all works when you use the UI because it constructs a connection by specifying that conn_type from the UI form.
It's a bug, the type name should be changed from hive_cli to hivecli, or something else that is descriptive and compatible with urlparse.
get_hookgithub.com/apache/incubator-airflow/blob/master/airflow/… - Davos