Skip to content

Commit 6fa9816

Browse files
NiallEgansusodapop
authored andcommitted
Rename metadata arg as http_header
Change `metadata` arg to `http_header` Existing unit tests
1 parent 592b762 commit 6fa9816

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

cmdexec/clients/python/src/databricks/sql/HISTORY

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ v2.0.0 - April 19, 2022
22
- Initial stable release of V2
33
- Added better support for complex types, so that in Databricks runtime 10.3+, Arrays, Maps and Structs will get
44
deserialized as lists, lists of tuples and dicts, respectively.
5+
- Changed the name of the metadata arg to http_headers
56

67
v2.0.b2 - April 4, 2022
78
- Change import of collections.Iterable to collections.abc.Iterable to make the library compatible with Python 3.10

cmdexec/clients/python/src/databricks/sql/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(self,
2525
server_hostname: str,
2626
http_path: str,
2727
access_token: str,
28-
metadata: Optional[List[Tuple[str, str]]] = None,
28+
http_headers: Optional[List[Tuple[str, str]]] = None,
2929
session_configuration: Dict[str, Any] = None,
3030
catalog: Optional[str] = None,
3131
schema: Optional[str] = None,
@@ -37,7 +37,7 @@ def __init__(self,
3737
:param http_path: Http path either to a DBSQL endpoint (e.g. /sql/1.0/endpoints/1234567890abcdef)
3838
or to a DBR interactive cluster (e.g. /sql/protocolv1/o/1234567890123456/1234-123456-slid123)
3939
:param access_token: Http Bearer access token, e.g. Databricks Personal Access Token.
40-
:param metadata: An optional list of (k, v) pairs that will be set as Http headers on every request
40+
:param http_headers: An optional list of (k, v) pairs that will be set as Http headers on every request
4141
:param session_configuration: An optional dictionary of Spark session parameters. Defaults to None.
4242
Execute the SQL command `SET -v` to get a full list of available commands.
4343
:param catalog: An optional initial catalog to use. Requires DBR version 9.0+
@@ -105,7 +105,7 @@ def __init__(self,
105105

106106
base_headers = [("User-Agent", useragent_header)] + authorization_header
107107
self.thrift_backend = ThriftBackend(self.host, self.port, http_path,
108-
(metadata or []) + base_headers, **kwargs)
108+
(http_headers or []) + base_headers, **kwargs)
109109

110110
self._session_handle = self.thrift_backend.open_session(session_configuration, catalog,
111111
schema)

cmdexec/clients/python/tests/tests.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ def test_auth_args(self, mock_client_class):
7979
connection.close()
8080

8181
@patch("%s.client.ThriftBackend" % PACKAGE_NAME)
82-
def test_metadata_passthrough(self, mock_client_class):
83-
metadata = [("foo", "bar")]
84-
databricks.sql.connect(**self.DUMMY_CONNECTION_ARGS, metadata=metadata)
82+
def test_http_header_passthrough(self, mock_client_class):
83+
http_headers = [("foo", "bar")]
84+
databricks.sql.connect(**self.DUMMY_CONNECTION_ARGS, http_headers=http_headers)
8585

86-
http_headers = mock_client_class.call_args[0][3]
87-
self.assertIn(("foo", "bar"), http_headers)
86+
call_args = mock_client_class.call_args[0][3]
87+
self.assertIn(("foo", "bar"), call_args)
8888

8989
@patch("%s.client.ThriftBackend" % PACKAGE_NAME)
9090
def test_authtoken_passthrough(self, mock_client_class):

0 commit comments

Comments
 (0)