Skip to content

Commit cadd7b6

Browse files
committed
fix: add flight info action
1 parent 4b64813 commit cadd7b6

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

src/query_farm_server_base/parameter_types.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,28 @@ class TableFunctionFlightInfo(BaseModel):
324324
)
325325

326326

327+
class FlightInfo(BaseModel):
328+
"""
329+
Parameters for a table function flight info request.
330+
"""
331+
332+
model_config = ConfigDict(arbitrary_types_allowed=True) # for Pydantic v2
333+
334+
# The descriptor of the table function.
335+
descriptor: flight.FlightDescriptor
336+
337+
at_unit: str | None = None
338+
at_value: str | None = None
339+
340+
_validate_flight_descriptor = field_validator("descriptor", mode="before")(
341+
deserialize_flight_descriptor
342+
)
343+
344+
345+
def flight_info(action: flight.Action) -> FlightInfo:
346+
return unpack_with_model(action, FlightInfo)
347+
348+
327349
def table_function_flight_info(action: flight.Action) -> TableFunctionFlightInfo:
328350
return unpack_with_model(action, TableFunctionFlightInfo)
329351

src/query_farm_server_base/server.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class ActionType(str, Enum):
116116
ENDPOINTS = "endpoints"
117117
LIST_SCHEMAS = "list_schemas"
118118
TABLE_FUNCTION_FLIGHT_INFO = "table_function_flight_info"
119+
FLIGHT_INFO = "flight_info"
119120

120121

121122
@dataclass
@@ -263,6 +264,13 @@ def __init__(
263264
False,
264265
False,
265266
),
267+
ActionType.TABLE_FUNCTION_FLIGHT_INFO: ActionHandlerSpec(
268+
self.action_flight_info,
269+
parameter_types.flight_info,
270+
lambda x: x.serialize(),
271+
False,
272+
False,
273+
),
266274
ActionType.LIST_SCHEMAS: ActionHandlerSpec(
267275
self.action_list_schemas,
268276
parameter_types.list_schemas,
@@ -536,6 +544,14 @@ def action_table_function_flight_info(
536544
) -> flight.FlightInfo:
537545
self._unimplemented_action(ActionType.TABLE_FUNCTION_FLIGHT_INFO)
538546

547+
def action_flight_info(
548+
self,
549+
*,
550+
context: CallContext[AccountType, TokenType],
551+
parameters: parameter_types.TableFunctionFlightInfo,
552+
) -> flight.FlightInfo:
553+
self._unimplemented_action(ActionType.FLIGHT_INFO)
554+
539555
@abstractmethod
540556
def action_catalog_version(
541557
self,

0 commit comments

Comments
 (0)