pyarrow 飞行错误:无法在关闭前完成写入

问题描述 投票:0回答:1

我有这段代码,我正在使用 pyarrow Flight 在 Dremio 中执行查询:

class DremioConnector:
    env: str
    auth_token: str

    def __init__(self, env: str,  auth_token: str):
        self.env = env
        self.auth_token = auth_token

    def get_dremio_client(self):
        dremio_url = get_url_from_template(DREMIO_URL, self.env)

        return FlightClient(f"grpc+tls://{dremio_url}:*****", tls_root_certs=get_cert(),
                            middleware=[DremioClientAuthMiddlewareFactory(), CookieMiddlewareFactory()], **{}, )

    def get_dremio_credentials(self):
       
        ...
        ...

        return username, password

    def __create_flight_call_options(self, username: str, password: str, client: FlightClient) -> FlightCallOptions:
        headers: list[Any] = []

        bearer_token = client.authenticate_basic_token(username, password, FlightCallOptions(headers=headers))
        headers.append(bearer_token)
        return FlightCallOptions(headers=headers)

    def run_query(self, query: str, username: str, password: str, client: FlightClient) -> FlightStreamReader:
        flight_desc = FlightDescriptor.for_command(query)
        flight_info = client.get_flight_info(flight_desc, self.__create_flight_call_options(username, password, client))
        reader = client.do_get(flight_info.endpoints[0].ticket, self.__create_flight_call_options(username, password, client))
        return reader


connector = DremioConnector('env', "auth_token")

dremio_client = connector.get_dremio_client()

最近我开始收到此错误: E pyarrow._flight.FlightInternalError:无法在关闭之前完成写入

打电话时

bearer_token = client.authenticate_basic_token(用户名,密码,FlightCallOptions(headers = headers))

有人知道可能是什么问题吗?我不知道为什么这个错误开始出现,因为它之前就工作过。我在这里做错了什么吗?

python pyarrow dremio apache-arrow-flight
1个回答
0
投票

这是我使用 PyArrow 连接到 Dremio 的代码,对于 Dremio Cloud 效果很好,希望这会有所帮助。

Dremio 的简单 PyArrow 客户端

© www.soinside.com 2019 - 2024. All rights reserved.