@@ -42,6 +42,10 @@ def file_parser_options(**kwargs):
42
42
43
43
44
44
def _deep_merge (target , source ):
45
+ """
46
+ Performs a deep merge of dictionaries or lists,
47
+ recursively merging the contents, handling nested structures, and concatenation of lists.
48
+ """
45
49
if isinstance (target , dict ) and isinstance (source , dict ):
46
50
for key , value in source .items ():
47
51
if key in target and isinstance (target [key ], (dict , list )) and isinstance (value , (dict , list )):
@@ -117,8 +121,10 @@ def __init__(
117
121
port = query_port_overwrite
118
122
self ._flight_client = FlightClient (f"grpc+tls://{ hostname } :{ port } " , ** self ._flight_client_options )
119
123
120
- # Merge defaults with user-provided arguments
121
124
def _merge_options (self , defaults , custom = {}):
125
+ """
126
+ Merge default option arguments with custom (user-provided) arguments.
127
+ """
122
128
if len (custom ) == 0 :
123
129
return defaults
124
130
return _deep_merge (defaults , {key : value for key , value in custom .items ()})
@@ -222,9 +228,7 @@ def query(self, query, language="sql", mode="all", database=None,**kwargs ):
222
228
"timeout" : 300
223
229
}
224
230
opts = self ._merge_options (optargs , kwargs )
225
- _options = FlightCallOptions (
226
- headers = opts ["headers" ],
227
- timeout = opts ["timeout" ])
231
+ _options = FlightCallOptions (** opts )
228
232
ticket_data = {"database" : database , "sql_query" : query , "query_type" : language }
229
233
ticket = Ticket (json .dumps (ticket_data ).encode ('utf-8' ))
230
234
flight_reader = self ._flight_client .do_get (ticket , _options )
0 commit comments