@@ -210,7 +210,7 @@ def action_list_schemas(
210
210
) -> base_server .AirportSerializedCatalogRoot :
211
211
assert context .caller is not None
212
212
213
- with DatabaseLibraryContext (context .caller .token .token ) as library :
213
+ with DatabaseLibraryContext (context .caller .token .token , readonly = True ) as library :
214
214
database = library .by_name (parameters .catalog_name )
215
215
216
216
dynamic_inventory : dict [str , dict [str , list [flight_inventory .FlightInventoryWithMetadata ]]] = {}
@@ -252,7 +252,7 @@ def impl_list_flights(
252
252
criteria : bytes ,
253
253
) -> Iterator [flight .FlightInfo ]:
254
254
assert context .caller is not None
255
- with DatabaseLibraryContext (context .caller .token .token ) as library :
255
+ with DatabaseLibraryContext (context .caller .token .token , readonly = True ) as library :
256
256
257
257
def yield_flight_infos () -> Generator [flight .FlightInfo , None , None ]:
258
258
for db_name , db in library .databases_by_name .items ():
@@ -272,7 +272,7 @@ def impl_get_flight_info(
272
272
assert context .caller is not None
273
273
274
274
descriptor_parts = descriptor_unpack_ (descriptor )
275
- with DatabaseLibraryContext (context .caller .token .token ) as library :
275
+ with DatabaseLibraryContext (context .caller .token .token , readonly = True ) as library :
276
276
database = library .by_name (descriptor_parts .catalog_name )
277
277
schema = database .by_name (descriptor_parts .schema_name )
278
278
@@ -1001,6 +1001,17 @@ def action_column_statistics(
1001
1001
min_value = sorted_contents [0 ]
1002
1002
max_value = sorted_contents [- 1 ]
1003
1003
1004
+ additional_values = {}
1005
+ additional_schema_fields = []
1006
+ if contents .type in (pa .string (), pa .utf8 (), pa .binary ()):
1007
+ max_length = pc .max (pc .binary_length (contents )).as_py ()
1008
+
1009
+ additional_values = {"max_string_length" : max_length , "contains_unicode" : contents .type == pa .utf8 ()}
1010
+ additional_schema_fields = [
1011
+ pa .field ("max_string_length" , pa .uint64 ()),
1012
+ pa .field ("contains_unicode" , pa .bool_ ()),
1013
+ ]
1014
+
1004
1015
if contents .type == pa .uuid ():
1005
1016
# For UUIDs, we need to convert them to strings for the output.
1006
1017
min_value = min_value .bytes
@@ -1014,6 +1025,7 @@ def action_column_statistics(
1014
1025
"distinct_count" : distinct_count ,
1015
1026
"min" : min_value ,
1016
1027
"max" : max_value ,
1028
+ ** additional_values ,
1017
1029
}
1018
1030
],
1019
1031
schema = pa .schema (
@@ -1023,6 +1035,7 @@ def action_column_statistics(
1023
1035
pa .field ("distinct_count" , pa .uint64 ()),
1024
1036
pa .field ("min" , contents .type ),
1025
1037
pa .field ("max" , contents .type ),
1038
+ * additional_schema_fields ,
1026
1039
]
1027
1040
),
1028
1041
)
0 commit comments