We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Using http for webhdfs not possible when kerberos is enabled 
The hdfs_connect function has no option to choose http or https protocol when connecting to webhdfs.
We are running CDH 5.5 with kerberos but without ssl enabled for webhdfs.

Could you maybe add an option to signal the use of http when using kerberos?

code snippet.

the hdfs_connect function code in ibis/ibis/**init**.py always uses https when auth_mechanism in ['GSSAPI', 'LDAP']

example:

def hdfs_connect(host='localhost', port=50070, protocol='webhdfs',
                 auth_mechanism='NOSASL', verify=True, use_https=True, **kwds):

if auth_mechanism in ['GSSAPI', 'LDAP']:
        try:
            import requests_kerberos
        except ImportError:
            raise IbisError(
                "Unable to import requests-kerberos, which is required for "
                "Kerberos HDFS support. Install it by executing `pip install "
                "requests-kerberos` or `pip install hdfs[kerberos]`.")
        from hdfs.ext.kerberos import KerberosClient
        if use_https:
            url = 'https://{0}:{1}'.format(host, port) # use SSL
        else:
            url = 'http://{0}:{1}'.format(host, port) # no SSL
        kwds.setdefault('mutual_auth', 'OPTIONAL')
        hdfs_client = KerberosClient(url, *_kwds)
    else:
        from hdfs.client import InsecureClient
        url = 'http://{0}:{1}'.format(host, port)
        hdfs_client = InsecureClient(url, *_kwds)


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `ibis/impala/api.py`
Content:
```
1 # Copyright 2015 Cloudera Inc
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 # http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13 
14 from ibis.impala.client import (ImpalaConnection,  # noqa
15                                 ImpalaClient,
16                                 ImpalaDatabase,
17                                 ImpalaTable)
18 from ibis.impala.udf import *  # noqa
19 from ibis.impala.madlib import MADLibAPI  # noqa
20 from ibis.config import options
21 import ibis.common as com
22 
23 
24 def compile(expr):
25     """
26     Force compilation of expression as though it were an expression depending
27     on Impala. Note you can also call expr.compile()
28 
29     Returns
30     -------
31     compiled : string
32     """
33     from .compiler import to_sql
34     return to_sql(expr)
35 
36 
37 def verify(expr):
38     """
39     Determine if expression can be successfully translated to execute on Impala
40     """
41     try:
42         compile(expr)
43         return True
44     except com.TranslationError:
45         return False
46 
47 
48 def connect(host='localhost', port=21050, database='default', timeout=45,
49             use_ssl=False, ca_cert=None, user=None, password=None,
50             auth_mechanism='NOSASL', kerberos_service_name='impala',
51             pool_size=8, hdfs_client=None):
52     """
53     Create an ImpalaClient for use with Ibis.
54 
55     Parameters
56     ----------
57     host : string, Host name of the impalad or HiveServer2 in Hive
58     port : int, Defaults to 21050 (Impala's HiveServer2)
59     database : string, Default database when obtaining new cursors
60     timeout : int, Connection timeout (seconds) when communicating with
61         HiveServer2
62     use_ssl : boolean, Use SSL when connecting to HiveServer2
63     ca_cert : string, Local path to 3rd party CA certificate or copy of server
64         certificate for self-signed certificates. If SSL is enabled, but this
65         argument is None, then certificate validation is skipped.
66     user : string, LDAP user to authenticate
67     password : string, LDAP password to authenticate
68     auth_mechanism : string, {'NOSASL' <- default, 'PLAIN', 'GSSAPI', 'LDAP'}.
69         Use NOSASL for non-secured Impala connections.  Use PLAIN for
70         non-secured Hive clusters.  Use LDAP for LDAP authenticated
71         connections.  Use GSSAPI for Kerberos-secured clusters.
72     kerberos_service_name : string, Specify particular impalad service
73         principal.
74 
75     Examples
76     --------
77     >>> hdfs = ibis.hdfs_connect(**hdfs_params)
78     >>> client = ibis.impala.connect(hdfs_client=hdfs, **impala_params)
79 
80     Returns
81     -------
82     con : ImpalaClient
83     """
84     params = {
85         'host': host,
86         'port': port,
87         'database': database,
88         'timeout': timeout,
89         'use_ssl': use_ssl,
90         'ca_cert': ca_cert,
91         'user': user,
92         'password': password,
93         'auth_mechanism': auth_mechanism,
94         'kerberos_service_name': kerberos_service_name
95     }
96 
97     con = ImpalaConnection(pool_size=pool_size, **params)
98     client = ImpalaClient(con, hdfs_client=hdfs_client)
99 
100     if options.default_backend is None:
101         options.default_backend = client
102 
103     return client
104
```

Path: `ibis/__init__.py`
Content:
```
1 # Copyright 2014 Cloudera Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 
16 # flake8: noqa
17 
18 __version__ = '0.5.0'
19 
20 from ibis.filesystems import HDFS, WebHDFS
21 from ibis.common import IbisError
22 
23 import ibis.expr.api as api
24 import ibis.expr.types as ir
25 
26 # __all__ is defined
27 from ibis.expr.api import *
28 
29 import ibis.impala.api as impala
30 import ibis.sql.sqlite.api as sqlite
31 
32 import ibis.config_init
33 from ibis.config import options
34 import ibis.util as util
35 
36 
37 # Deprecated
38 impala_connect = util.deprecate(impala.connect,
39                                 'impala_connect is deprecated, use'
40                                 ' ibis.impala.connect instead')
41 
42 
43 def make_client(db, hdfs_client=None):
44     """
45     Create an Ibis client from a database connection and optional additional
46     connections (like HDFS)
47 
48     Parameters
49     ----------
50     db : Connection
51       e.g. produced by ibis.impala.connect
52     hdfs_client : ibis HDFS client
53 
54     Examples
55     --------
56     >>> con = ibis.impala.connect(**impala_params)
57     >>> hdfs = ibis.hdfs_connect(**hdfs_params)
58     >>> client = ibis.make_client(con, hdfs_client=hdfs)
59 
60     Returns
61     -------
62     client : IbisClient
63     """
64     db._hdfs = hdfs_client
65     return db
66 
67 make_client = util.deprecate(
68     make_client, ('make_client is deprecated. '
69                   'Use ibis.impala.connect '
70                   ' with hdfs_client=hdfs_client'))
71 
72 
73 def hdfs_connect(host='localhost', port=50070, protocol='webhdfs',
74                  auth_mechanism='NOSASL', verify=True, **kwds):
75     """
76     Connect to HDFS
77 
78     Parameters
79     ----------
80     host : string, Host name of the HDFS NameNode
81     port : int, NameNode's WebHDFS port (default 50070)
82     protocol : {'webhdfs'}
83     auth_mechanism : string, Set to NOSASL or PLAIN for non-secure clusters.
84         Set to GSSAPI or LDAP for Kerberos-secured clusters.
85     verify : boolean, Set to False to turn off verifying SSL certificates.
86         (default True)
87 
88     Other keywords are forwarded to hdfs library classes
89 
90     Returns
91     -------
92     client : WebHDFS
93     """
94     import requests
95     session = kwds.setdefault('session', requests.Session())
96     session.verify = verify
97     if auth_mechanism in ['GSSAPI', 'LDAP']:
98         try:
99             import requests_kerberos
100         except ImportError:
101             raise IbisError(
102                 "Unable to import requests-kerberos, which is required for "
103                 "Kerberos HDFS support. Install it by executing `pip install "
104                 "requests-kerberos` or `pip install hdfs[kerberos]`.")
105         from hdfs.ext.kerberos import KerberosClient
106         url = 'https://{0}:{1}'.format(host, port) # note SSL
107         kwds.setdefault('mutual_auth', 'OPTIONAL')
108         hdfs_client = KerberosClient(url, **kwds)
109     else:
110         from hdfs.client import InsecureClient
111         url = 'http://{0}:{1}'.format(host, port)
112         hdfs_client = InsecureClient(url, **kwds)
113     return WebHDFS(hdfs_client)
114 
115 def test(impala=False):
116     import pytest
117     import ibis
118     import os
119 
120     ibis_dir, _ = os.path.split(ibis.__file__)
121 
122     args = ['--pyargs', ibis_dir]
123     if impala:
124         args.append('--impala')
125     pytest.main(args)
126 
127 from ._version import get_versions
128 __version__ = get_versions()['version']
129 del get_versions
130
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/ibis/__init__.py b/ibis/__init__.py
--- a/ibis/__init__.py
+++ b/ibis/__init__.py
@@ -71,7 +71,8 @@
 
 
 def hdfs_connect(host='localhost', port=50070, protocol='webhdfs',
-                 auth_mechanism='NOSASL', verify=True, **kwds):
+                 use_https='default', auth_mechanism='NOSASL',
+                 verify=True, **kwds):
     """
     Connect to HDFS
 
@@ -80,6 +81,9 @@
     host : string, Host name of the HDFS NameNode
     port : int, NameNode's WebHDFS port (default 50070)
     protocol : {'webhdfs'}
+    use_https : boolean, default 'default'
+        Connect to WebHDFS with HTTPS, otherwise plain HTTP. For secure
+        authentication, the default for this is True, otherwise False
     auth_mechanism : string, Set to NOSASL or PLAIN for non-secure clusters.
         Set to GSSAPI or LDAP for Kerberos-secured clusters.
     verify : boolean, Set to False to turn off verifying SSL certificates.
@@ -95,6 +99,10 @@
     session = kwds.setdefault('session', requests.Session())
     session.verify = verify
     if auth_mechanism in ['GSSAPI', 'LDAP']:
+        if use_https == 'default':
+            prefix = 'https'
+        else:
+            prefix = 'https' if use_https else 'http'
         try:
             import requests_kerberos
         except ImportError:
@@ -103,12 +111,17 @@
                 "Kerberos HDFS support. Install it by executing `pip install "
                 "requests-kerberos` or `pip install hdfs[kerberos]`.")
         from hdfs.ext.kerberos import KerberosClient
-        url = 'https://{0}:{1}'.format(host, port) # note SSL
+        # note SSL
+        url = '{0}://{1}:{2}'.format(prefix, host, port)
         kwds.setdefault('mutual_auth', 'OPTIONAL')
         hdfs_client = KerberosClient(url, **kwds)
     else:
+        if use_https == 'default':
+            prefix = 'http'
+        else:
+            prefix = 'https' if use_https else 'http'
         from hdfs.client import InsecureClient
-        url = 'http://{0}:{1}'.format(host, port)
+        url = '{0}://{1}:{2}'.format(prefix, host, port)
         hdfs_client = InsecureClient(url, **kwds)
     return WebHDFS(hdfs_client)
 
diff --git a/ibis/impala/api.py b/ibis/impala/api.py
--- a/ibis/impala/api.py
+++ b/ibis/impala/api.py
@@ -46,9 +46,9 @@
 
 
 def connect(host='localhost', port=21050, database='default', timeout=45,
-            use_ssl=False, ca_cert=None, user=None, password=None,
-            auth_mechanism='NOSASL', kerberos_service_name='impala',
-            pool_size=8, hdfs_client=None):
+            use_ssl=False, ca_cert=None, user=None,
+            password=None, auth_mechanism='NOSASL',
+            kerberos_service_name='impala', pool_size=8, hdfs_client=None):
     """
     Create an ImpalaClient for use with Ibis.

{"golden_diff": "diff --git a/ibis/__init__.py b/ibis/__init__.py\n--- a/ibis/__init__.py\n+++ b/ibis/__init__.py\n@@ -71,7 +71,8 @@\n \n \n def hdfs_connect(host='localhost', port=50070, protocol='webhdfs',\n-                 auth_mechanism='NOSASL', verify=True, **kwds):\n+                 use_https='default', auth_mechanism='NOSASL',\n+                 verify=True, **kwds):\n     \"\"\"\n     Connect to HDFS\n \n@@ -80,6 +81,9 @@\n     host : string, Host name of the HDFS NameNode\n     port : int, NameNode's WebHDFS port (default 50070)\n     protocol : {'webhdfs'}\n+    use_https : boolean, default 'default'\n+        Connect to WebHDFS with HTTPS, otherwise plain HTTP. For secure\n+        authentication, the default for this is True, otherwise False\n     auth_mechanism : string, Set to NOSASL or PLAIN for non-secure clusters.\n         Set to GSSAPI or LDAP for Kerberos-secured clusters.\n     verify : boolean, Set to False to turn off verifying SSL certificates.\n@@ -95,6 +99,10 @@\n     session = kwds.setdefault('session', requests.Session())\n     session.verify = verify\n     if auth_mechanism in ['GSSAPI', 'LDAP']:\n+        if use_https == 'default':\n+            prefix = 'https'\n+        else:\n+            prefix = 'https' if use_https else 'http'\n         try:\n             import requests_kerberos\n         except ImportError:\n@@ -103,12 +111,17 @@\n                 \"Kerberos HDFS support. Install it by executing `pip install \"\n                 \"requests-kerberos` or `pip install hdfs[kerberos]`.\")\n         from hdfs.ext.kerberos import KerberosClient\n-        url = 'https://{0}:{1}'.format(host, port) # note SSL\n+        # note SSL\n+        url = '{0}://{1}:{2}'.format(prefix, host, port)\n         kwds.setdefault('mutual_auth', 'OPTIONAL')\n         hdfs_client = KerberosClient(url, **kwds)\n     else:\n+        if use_https == 'default':\n+            prefix = 'http'\n+        else:\n+            prefix = 'https' if use_https else 'http'\n         from hdfs.client import InsecureClient\n-        url = 'http://{0}:{1}'.format(host, port)\n+        url = '{0}://{1}:{2}'.format(prefix, host, port)\n         hdfs_client = InsecureClient(url, **kwds)\n     return WebHDFS(hdfs_client)\n \ndiff --git a/ibis/impala/api.py b/ibis/impala/api.py\n--- a/ibis/impala/api.py\n+++ b/ibis/impala/api.py\n@@ -46,9 +46,9 @@\n \n \n def connect(host='localhost', port=21050, database='default', timeout=45,\n-            use_ssl=False, ca_cert=None, user=None, password=None,\n-            auth_mechanism='NOSASL', kerberos_service_name='impala',\n-            pool_size=8, hdfs_client=None):\n+            use_ssl=False, ca_cert=None, user=None,\n+            password=None, auth_mechanism='NOSASL',\n+            kerberos_service_name='impala', pool_size=8, hdfs_client=None):\n     \"\"\"\n     Create an ImpalaClient for use with Ibis.\n", "issue": "Using http for webhdfs not possible when kerberos is enabled \nThe hdfs_connect function has no option to choose http or https protocol when connecting to webhdfs.\nWe are running CDH 5.5 with kerberos but without ssl enabled for webhdfs.\n\nCould you maybe add an option to signal the use of http when using kerberos?\n\ncode snippet.\n\nthe hdfs_connect function code in ibis/ibis/**init**.py always uses https when auth_mechanism in ['GSSAPI', 'LDAP']\n\nexample:\n\ndef hdfs_connect(host='localhost', port=50070, protocol='webhdfs',\n                 auth_mechanism='NOSASL', verify=True, use_https=True, **kwds):\n\nif auth_mechanism in ['GSSAPI', 'LDAP']:\n        try:\n            import requests_kerberos\n        except ImportError:\n            raise IbisError(\n                \"Unable to import requests-kerberos, which is required for \"\n                \"Kerberos HDFS support. Install it by executing `pip install \"\n                \"requests-kerberos` or `pip install hdfs[kerberos]`.\")\n        from hdfs.ext.kerberos import KerberosClient\n        if use_https:\n            url = 'https://{0}:{1}'.format(host, port) # use SSL\n        else:\n            url = 'http://{0}:{1}'.format(host, port) # no SSL\n        kwds.setdefault('mutual_auth', 'OPTIONAL')\n        hdfs_client = KerberosClient(url, *_kwds)\n    else:\n        from hdfs.client import InsecureClient\n        url = 'http://{0}:{1}'.format(host, port)\n        hdfs_client = InsecureClient(url, *_kwds)\n\n", "before_files": [{"content": "# Copyright 2015 Cloudera Inc\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom ibis.impala.client import (ImpalaConnection,  # noqa\n                                ImpalaClient,\n                                ImpalaDatabase,\n                                ImpalaTable)\nfrom ibis.impala.udf import *  # noqa\nfrom ibis.impala.madlib import MADLibAPI  # noqa\nfrom ibis.config import options\nimport ibis.common as com\n\n\ndef compile(expr):\n    \"\"\"\n    Force compilation of expression as though it were an expression depending\n    on Impala. Note you can also call expr.compile()\n\n    Returns\n    -------\n    compiled : string\n    \"\"\"\n    from .compiler import to_sql\n    return to_sql(expr)\n\n\ndef verify(expr):\n    \"\"\"\n    Determine if expression can be successfully translated to execute on Impala\n    \"\"\"\n    try:\n        compile(expr)\n        return True\n    except com.TranslationError:\n        return False\n\n\ndef connect(host='localhost', port=21050, database='default', timeout=45,\n            use_ssl=False, ca_cert=None, user=None, password=None,\n            auth_mechanism='NOSASL', kerberos_service_name='impala',\n            pool_size=8, hdfs_client=None):\n    \"\"\"\n    Create an ImpalaClient for use with Ibis.\n\n    Parameters\n    ----------\n    host : string, Host name of the impalad or HiveServer2 in Hive\n    port : int, Defaults to 21050 (Impala's HiveServer2)\n    database : string, Default database when obtaining new cursors\n    timeout : int, Connection timeout (seconds) when communicating with\n        HiveServer2\n    use_ssl : boolean, Use SSL when connecting to HiveServer2\n    ca_cert : string, Local path to 3rd party CA certificate or copy of server\n        certificate for self-signed certificates. If SSL is enabled, but this\n        argument is None, then certificate validation is skipped.\n    user : string, LDAP user to authenticate\n    password : string, LDAP password to authenticate\n    auth_mechanism : string, {'NOSASL' <- default, 'PLAIN', 'GSSAPI', 'LDAP'}.\n        Use NOSASL for non-secured Impala connections.  Use PLAIN for\n        non-secured Hive clusters.  Use LDAP for LDAP authenticated\n        connections.  Use GSSAPI for Kerberos-secured clusters.\n    kerberos_service_name : string, Specify particular impalad service\n        principal.\n\n    Examples\n    --------\n    >>> hdfs = ibis.hdfs_connect(**hdfs_params)\n    >>> client = ibis.impala.connect(hdfs_client=hdfs, **impala_params)\n\n    Returns\n    -------\n    con : ImpalaClient\n    \"\"\"\n    params = {\n        'host': host,\n        'port': port,\n        'database': database,\n        'timeout': timeout,\n        'use_ssl': use_ssl,\n        'ca_cert': ca_cert,\n        'user': user,\n        'password': password,\n        'auth_mechanism': auth_mechanism,\n        'kerberos_service_name': kerberos_service_name\n    }\n\n    con = ImpalaConnection(pool_size=pool_size, **params)\n    client = ImpalaClient(con, hdfs_client=hdfs_client)\n\n    if options.default_backend is None:\n        options.default_backend = client\n\n    return client\n", "path": "ibis/impala/api.py"}, {"content": "# Copyright 2014 Cloudera Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\n# flake8: noqa\n\n__version__ = '0.5.0'\n\nfrom ibis.filesystems import HDFS, WebHDFS\nfrom ibis.common import IbisError\n\nimport ibis.expr.api as api\nimport ibis.expr.types as ir\n\n# __all__ is defined\nfrom ibis.expr.api import *\n\nimport ibis.impala.api as impala\nimport ibis.sql.sqlite.api as sqlite\n\nimport ibis.config_init\nfrom ibis.config import options\nimport ibis.util as util\n\n\n# Deprecated\nimpala_connect = util.deprecate(impala.connect,\n                                'impala_connect is deprecated, use'\n                                ' ibis.impala.connect instead')\n\n\ndef make_client(db, hdfs_client=None):\n    \"\"\"\n    Create an Ibis client from a database connection and optional additional\n    connections (like HDFS)\n\n    Parameters\n    ----------\n    db : Connection\n      e.g. produced by ibis.impala.connect\n    hdfs_client : ibis HDFS client\n\n    Examples\n    --------\n    >>> con = ibis.impala.connect(**impala_params)\n    >>> hdfs = ibis.hdfs_connect(**hdfs_params)\n    >>> client = ibis.make_client(con, hdfs_client=hdfs)\n\n    Returns\n    -------\n    client : IbisClient\n    \"\"\"\n    db._hdfs = hdfs_client\n    return db\n\nmake_client = util.deprecate(\n    make_client, ('make_client is deprecated. '\n                  'Use ibis.impala.connect '\n                  ' with hdfs_client=hdfs_client'))\n\n\ndef hdfs_connect(host='localhost', port=50070, protocol='webhdfs',\n                 auth_mechanism='NOSASL', verify=True, **kwds):\n    \"\"\"\n    Connect to HDFS\n\n    Parameters\n    ----------\n    host : string, Host name of the HDFS NameNode\n    port : int, NameNode's WebHDFS port (default 50070)\n    protocol : {'webhdfs'}\n    auth_mechanism : string, Set to NOSASL or PLAIN for non-secure clusters.\n        Set to GSSAPI or LDAP for Kerberos-secured clusters.\n    verify : boolean, Set to False to turn off verifying SSL certificates.\n        (default True)\n\n    Other keywords are forwarded to hdfs library classes\n\n    Returns\n    -------\n    client : WebHDFS\n    \"\"\"\n    import requests\n    session = kwds.setdefault('session', requests.Session())\n    session.verify = verify\n    if auth_mechanism in ['GSSAPI', 'LDAP']:\n        try:\n            import requests_kerberos\n        except ImportError:\n            raise IbisError(\n                \"Unable to import requests-kerberos, which is required for \"\n                \"Kerberos HDFS support. Install it by executing `pip install \"\n                \"requests-kerberos` or `pip install hdfs[kerberos]`.\")\n        from hdfs.ext.kerberos import KerberosClient\n        url = 'https://{0}:{1}'.format(host, port) # note SSL\n        kwds.setdefault('mutual_auth', 'OPTIONAL')\n        hdfs_client = KerberosClient(url, **kwds)\n    else:\n        from hdfs.client import InsecureClient\n        url = 'http://{0}:{1}'.format(host, port)\n        hdfs_client = InsecureClient(url, **kwds)\n    return WebHDFS(hdfs_client)\n\ndef test(impala=False):\n    import pytest\n    import ibis\n    import os\n\n    ibis_dir, _ = os.path.split(ibis.__file__)\n\n    args = ['--pyargs', ibis_dir]\n    if impala:\n        args.append('--impala')\n    pytest.main(args)\n\nfrom ._version import get_versions\n__version__ = get_versions()['version']\ndel get_versions\n", "path": "ibis/__init__.py"}], "after_files": [{"content": "# Copyright 2015 Cloudera Inc\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom ibis.impala.client import (ImpalaConnection,  # noqa\n                                ImpalaClient,\n                                ImpalaDatabase,\n                                ImpalaTable)\nfrom ibis.impala.udf import *  # noqa\nfrom ibis.impala.madlib import MADLibAPI  # noqa\nfrom ibis.config import options\nimport ibis.common as com\n\n\ndef compile(expr):\n    \"\"\"\n    Force compilation of expression as though it were an expression depending\n    on Impala. Note you can also call expr.compile()\n\n    Returns\n    -------\n    compiled : string\n    \"\"\"\n    from .compiler import to_sql\n    return to_sql(expr)\n\n\ndef verify(expr):\n    \"\"\"\n    Determine if expression can be successfully translated to execute on Impala\n    \"\"\"\n    try:\n        compile(expr)\n        return True\n    except com.TranslationError:\n        return False\n\n\ndef connect(host='localhost', port=21050, database='default', timeout=45,\n            use_ssl=False, ca_cert=None, user=None,\n            password=None, auth_mechanism='NOSASL',\n            kerberos_service_name='impala', pool_size=8, hdfs_client=None):\n    \"\"\"\n    Create an ImpalaClient for use with Ibis.\n\n    Parameters\n    ----------\n    host : string, Host name of the impalad or HiveServer2 in Hive\n    port : int, Defaults to 21050 (Impala's HiveServer2)\n    database : string, Default database when obtaining new cursors\n    timeout : int, Connection timeout (seconds) when communicating with\n        HiveServer2\n    use_ssl : boolean, Use SSL when connecting to HiveServer2\n    ca_cert : string, Local path to 3rd party CA certificate or copy of server\n        certificate for self-signed certificates. If SSL is enabled, but this\n        argument is None, then certificate validation is skipped.\n    user : string, LDAP user to authenticate\n    password : string, LDAP password to authenticate\n    auth_mechanism : string, {'NOSASL' <- default, 'PLAIN', 'GSSAPI', 'LDAP'}.\n        Use NOSASL for non-secured Impala connections.  Use PLAIN for\n        non-secured Hive clusters.  Use LDAP for LDAP authenticated\n        connections.  Use GSSAPI for Kerberos-secured clusters.\n    kerberos_service_name : string, Specify particular impalad service\n        principal.\n\n    Examples\n    --------\n    >>> hdfs = ibis.hdfs_connect(**hdfs_params)\n    >>> client = ibis.impala.connect(hdfs_client=hdfs, **impala_params)\n\n    Returns\n    -------\n    con : ImpalaClient\n    \"\"\"\n    params = {\n        'host': host,\n        'port': port,\n        'database': database,\n        'timeout': timeout,\n        'use_ssl': use_ssl,\n        'ca_cert': ca_cert,\n        'user': user,\n        'password': password,\n        'auth_mechanism': auth_mechanism,\n        'kerberos_service_name': kerberos_service_name\n    }\n\n    con = ImpalaConnection(pool_size=pool_size, **params)\n    client = ImpalaClient(con, hdfs_client=hdfs_client)\n\n    if options.default_backend is None:\n        options.default_backend = client\n\n    return client\n", "path": "ibis/impala/api.py"}, {"content": "# Copyright 2014 Cloudera Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\n# flake8: noqa\n\n__version__ = '0.5.0'\n\nfrom ibis.filesystems import HDFS, WebHDFS\nfrom ibis.common import IbisError\n\nimport ibis.expr.api as api\nimport ibis.expr.types as ir\n\n# __all__ is defined\nfrom ibis.expr.api import *\n\nimport ibis.impala.api as impala\nimport ibis.sql.sqlite.api as sqlite\n\nimport ibis.config_init\nfrom ibis.config import options\nimport ibis.util as util\n\n\n# Deprecated\nimpala_connect = util.deprecate(impala.connect,\n                                'impala_connect is deprecated, use'\n                                ' ibis.impala.connect instead')\n\n\ndef make_client(db, hdfs_client=None):\n    \"\"\"\n    Create an Ibis client from a database connection and optional additional\n    connections (like HDFS)\n\n    Parameters\n    ----------\n    db : Connection\n      e.g. produced by ibis.impala.connect\n    hdfs_client : ibis HDFS client\n\n    Examples\n    --------\n    >>> con = ibis.impala.connect(**impala_params)\n    >>> hdfs = ibis.hdfs_connect(**hdfs_params)\n    >>> client = ibis.make_client(con, hdfs_client=hdfs)\n\n    Returns\n    -------\n    client : IbisClient\n    \"\"\"\n    db._hdfs = hdfs_client\n    return db\n\nmake_client = util.deprecate(\n    make_client, ('make_client is deprecated. '\n                  'Use ibis.impala.connect '\n                  ' with hdfs_client=hdfs_client'))\n\n\ndef hdfs_connect(host='localhost', port=50070, protocol='webhdfs',\n                 use_https='default', auth_mechanism='NOSASL',\n                 verify=True, **kwds):\n    \"\"\"\n    Connect to HDFS\n\n    Parameters\n    ----------\n    host : string, Host name of the HDFS NameNode\n    port : int, NameNode's WebHDFS port (default 50070)\n    protocol : {'webhdfs'}\n    use_https : boolean, default 'default'\n        Connect to WebHDFS with HTTPS, otherwise plain HTTP. For secure\n        authentication, the default for this is True, otherwise False\n    auth_mechanism : string, Set to NOSASL or PLAIN for non-secure clusters.\n        Set to GSSAPI or LDAP for Kerberos-secured clusters.\n    verify : boolean, Set to False to turn off verifying SSL certificates.\n        (default True)\n\n    Other keywords are forwarded to hdfs library classes\n\n    Returns\n    -------\n    client : WebHDFS\n    \"\"\"\n    import requests\n    session = kwds.setdefault('session', requests.Session())\n    session.verify = verify\n    if auth_mechanism in ['GSSAPI', 'LDAP']:\n        if use_https == 'default':\n            prefix = 'https'\n        else:\n            prefix = 'https' if use_https else 'http'\n        try:\n            import requests_kerberos\n        except ImportError:\n            raise IbisError(\n                \"Unable to import requests-kerberos, which is required for \"\n                \"Kerberos HDFS support. Install it by executing `pip install \"\n                \"requests-kerberos` or `pip install hdfs[kerberos]`.\")\n        from hdfs.ext.kerberos import KerberosClient\n        # note SSL\n        url = '{0}://{1}:{2}'.format(prefix, host, port)\n        kwds.setdefault('mutual_auth', 'OPTIONAL')\n        hdfs_client = KerberosClient(url, **kwds)\n    else:\n        if use_https == 'default':\n            prefix = 'http'\n        else:\n            prefix = 'https' if use_https else 'http'\n        from hdfs.client import InsecureClient\n        url = '{0}://{1}:{2}'.format(prefix, host, port)\n        hdfs_client = InsecureClient(url, **kwds)\n    return WebHDFS(hdfs_client)\n\ndef test(impala=False):\n    import pytest\n    import ibis\n    import os\n\n    ibis_dir, _ = os.path.split(ibis.__file__)\n\n    args = ['--pyargs', ibis_dir]\n    if impala:\n        args.append('--impala')\n    pytest.main(args)\n\nfrom ._version import get_versions\n__version__ = get_versions()['version']\ndel get_versions\n", "path": "ibis/__init__.py"}]}