|
91 | 91 |
|
92 | 92 | NO_NATIVE_PARAMS: List = [] |
93 | 93 |
|
| 94 | +# All recognized **kwargs keys consumed by Connection.__init__ and the callees it |
| 95 | +# dispatches to (build_client_context, Session.__init__, get_python_sql_connector_auth_provider). |
| 96 | +# Any key passed by the caller that is NOT in this set will trigger a warning. |
| 97 | +KNOWN_KWARGS: frozenset = frozenset( |
| 98 | + { |
| 99 | + # client.py |
| 100 | + "access_token", |
| 101 | + "enable_metric_view_metadata", |
| 102 | + "_disable_pandas", |
| 103 | + "enable_query_result_lz4_compression", |
| 104 | + "use_cloud_fetch", |
| 105 | + "telemetry_batch_size", |
| 106 | + "enable_telemetry", |
| 107 | + "force_enable_telemetry", |
| 108 | + "use_inline_params", |
| 109 | + "staging_allowed_local_path", |
| 110 | + "fetch_autocommit_from_server", |
| 111 | + "pool_maxsize", |
| 112 | + "use_hybrid_disposition", |
| 113 | + # session.py |
| 114 | + "_port", |
| 115 | + "user_agent_entry", |
| 116 | + "_user_agent_entry", |
| 117 | + "use_sea", |
| 118 | + # SSL / TLS options (session.py, utils.py, auth/auth.py) |
| 119 | + "_tls_no_verify", |
| 120 | + "_tls_verify_hostname", |
| 121 | + "_tls_trusted_ca_file", |
| 122 | + "_tls_client_cert_file", |
| 123 | + "_tls_client_cert_key_file", |
| 124 | + "_tls_client_cert_key_password", |
| 125 | + "_use_cert_as_auth", |
| 126 | + "_enable_ssl", |
| 127 | + "_skip_routing_headers", |
| 128 | + # auth/auth.py |
| 129 | + "auth_type", |
| 130 | + "username", |
| 131 | + "password", |
| 132 | + "oauth_client_id", |
| 133 | + "oauth_redirect_port", |
| 134 | + "azure_client_id", |
| 135 | + "azure_client_secret", |
| 136 | + "azure_tenant_id", |
| 137 | + "azure_workspace_resource_id", |
| 138 | + "experimental_oauth_persistence", |
| 139 | + "credentials_provider", |
| 140 | + "identity_federation_client_id", |
| 141 | + # utils.py / build_client_context |
| 142 | + "_socket_timeout", |
| 143 | + "_retry_stop_after_attempts_count", |
| 144 | + "_retry_delay_min", |
| 145 | + "_retry_delay_max", |
| 146 | + "_retry_stop_after_attempts_duration", |
| 147 | + "_retry_delay_default", |
| 148 | + "_retry_dangerous_codes", |
| 149 | + "_proxy_auth_method", |
| 150 | + "_pool_connections", |
| 151 | + "_pool_maxsize", |
| 152 | + "telemetry_circuit_breaker_enabled", |
| 153 | + # thrift_backend.py |
| 154 | + "_connection_uri", |
| 155 | + "_use_arrow_native_decimals", |
| 156 | + "_use_arrow_native_timestamps", |
| 157 | + "max_download_threads", |
| 158 | + "_enable_v3_retries", |
| 159 | + "_retry_max_redirects", |
| 160 | + # sea/utils/http_client.py |
| 161 | + "max_connections", |
| 162 | + } |
| 163 | +) |
| 164 | + |
94 | 165 | # Transaction isolation level constants (extension to PEP 249) |
95 | 166 | TRANSACTION_ISOLATION_LEVEL_REPEATABLE_READ = "REPEATABLE_READ" |
96 | 167 |
|
@@ -271,6 +342,10 @@ def read(self) -> Optional[OAuthToken]: |
271 | 342 | http_path, |
272 | 343 | ) |
273 | 344 |
|
| 345 | + unknown = set(kwargs.keys()) - KNOWN_KWARGS |
| 346 | + if unknown: |
| 347 | + logger.warning("Unrecognized connection parameter(s): %s", unknown) |
| 348 | + |
274 | 349 | if access_token: |
275 | 350 | access_token_kv = {"access_token": access_token} |
276 | 351 | kwargs = {**kwargs, **access_token_kv} |
@@ -326,9 +401,9 @@ def read(self) -> Optional[OAuthToken]: |
326 | 401 | http_path=http_path, |
327 | 402 | port=kwargs.get("_port", 443), |
328 | 403 | client_context=client_context, |
329 | | - user_agent=self.session.useragent_header |
330 | | - if hasattr(self, "session") |
331 | | - else None, |
| 404 | + user_agent=( |
| 405 | + self.session.useragent_header if hasattr(self, "session") else None |
| 406 | + ), |
332 | 407 | enable_telemetry=enable_telemetry, |
333 | 408 | ) |
334 | 409 | raise e |
@@ -375,9 +450,11 @@ def read(self) -> Optional[OAuthToken]: |
375 | 450 |
|
376 | 451 | driver_connection_params = DriverConnectionParameters( |
377 | 452 | http_path=http_path, |
378 | | - mode=DatabricksClientType.SEA |
379 | | - if self.session.use_sea |
380 | | - else DatabricksClientType.THRIFT, |
| 453 | + mode=( |
| 454 | + DatabricksClientType.SEA |
| 455 | + if self.session.use_sea |
| 456 | + else DatabricksClientType.THRIFT |
| 457 | + ), |
381 | 458 | host_info=HostDetails(host_url=server_hostname, port=self.session.port), |
382 | 459 | auth_mech=TelemetryHelper.get_auth_mechanism(self.session.auth_provider), |
383 | 460 | auth_flow=TelemetryHelper.get_auth_flow(self.session.auth_provider), |
|
0 commit comments