@@ -210,7 +210,7 @@ def action_list_schemas(
210210 ) -> base_server .AirportSerializedCatalogRoot :
211211 assert context .caller is not None
212212
213- with DatabaseLibraryContext (context .caller .token .token ) as library :
213+ with DatabaseLibraryContext (context .caller .token .token , readonly = True ) as library :
214214 database = library .by_name (parameters .catalog_name )
215215
216216 dynamic_inventory : dict [str , dict [str , list [flight_inventory .FlightInventoryWithMetadata ]]] = {}
@@ -252,7 +252,7 @@ def impl_list_flights(
252252 criteria : bytes ,
253253 ) -> Iterator [flight .FlightInfo ]:
254254 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 :
256256
257257 def yield_flight_infos () -> Generator [flight .FlightInfo , None , None ]:
258258 for db_name , db in library .databases_by_name .items ():
@@ -272,7 +272,7 @@ def impl_get_flight_info(
272272 assert context .caller is not None
273273
274274 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 :
276276 database = library .by_name (descriptor_parts .catalog_name )
277277 schema = database .by_name (descriptor_parts .schema_name )
278278
@@ -1001,6 +1001,17 @@ def action_column_statistics(
10011001 min_value = sorted_contents [0 ]
10021002 max_value = sorted_contents [- 1 ]
10031003
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+
10041015 if contents .type == pa .uuid ():
10051016 # For UUIDs, we need to convert them to strings for the output.
10061017 min_value = min_value .bytes
@@ -1014,6 +1025,7 @@ def action_column_statistics(
10141025 "distinct_count" : distinct_count ,
10151026 "min" : min_value ,
10161027 "max" : max_value ,
1028+ ** additional_values ,
10171029 }
10181030 ],
10191031 schema = pa .schema (
@@ -1023,6 +1035,7 @@ def action_column_statistics(
10231035 pa .field ("distinct_count" , pa .uint64 ()),
10241036 pa .field ("min" , contents .type ),
10251037 pa .field ("max" , contents .type ),
1038+ * additional_schema_fields ,
10261039 ]
10271040 ),
10281041 )
0 commit comments