influxdata / influxdata/docs-v2
Add query example for pyarrow.flight FlightClient
- Dominant language
- JavaScript
- Stars
- 82
- Forks
- 326
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 82
Description
Provide a v3 query example using `pyarrow.flight` `FlightClient`.
Add `pyarrow.flight` to Flight SQL clients reference.
Some sample code that doesn't yet work. Token authentication still apparently requires middleware or inserting the auth header in a way that isn't clear in the docs or code.
```py
from pyarrow.flight import FlightClient, Ticket, \
FlightCallOptions, Action, \
ClientMiddleware
import json
import pandas as pd
import os
DATABASE_NAME = os.getenv('CLOUD_SERVERLESS_BUCKET_NAME')
DATABASE_TOKEN = os.getenv('CLOUD_SERVERLESS_READ_WRITE_TOKEN')
INFLUXDB_HOST=os.getenv('CLOUD_SERVERLESS_HOST')
# influxql = "SELECT MEAN(elapsed) FROM home WHERE time >= '2023-04-07 19:35:19.314571143' AND time <= '2023-04-07 21:51:29.638717686' GROUP BY time(10m)"
client = FlightClient(f"grpc+tls://{INFLUXDB_HOST}:443")
token_bytes = bytes(f"Bearer {DATABASE_TOKEN}".encode('utf-8'))
token_pair = (b'authorization', token_bytes)
database = (b'database', bytes(DATABASE_NAME.encode('utf-8')))
options = FlightCallOptions(headers=[token_pair, database])
# do_action = client.do_action(action, options)
# client.authenticate(options)
def test_sql_query():
sql = "SELECT * FROM home where room like 'telegraf%'"
ticket_data = {
"sql_query": sql,
"query_type": "sql"
}
ticket_bytes = json.dumps(ticket_data)
ticket = Ticket(ticket_bytes)
reader = client.do_get(ticket=ticket, options=options)
arrow_table = reader.read_all()
# data_frame = arrow_table.to_pandas()
# print(data_frame.to_markdown())
test_sql_query()
```
##### Relevant URLs
- _Provide relevant URLs (issues, community threads, existing doc pages, etc.)_
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the provided pyarrow.flight FlightClient sample and the existing Flight SQL clients reference. Verify how token authentication works for the v3 query example, then document a working example and add pyarrow.flight to the client list. Done means the example runs with authentication and the reference includes the client.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- databases, documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100