Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add query capability to Python plugin API #25757

Closed
pauldix opened this issue Jan 7, 2025 · 0 comments · Fixed by #25766
Closed

Add query capability to Python plugin API #25757

pauldix opened this issue Jan 7, 2025 · 0 comments · Fixed by #25766
Assignees
Labels

Comments

@pauldix
Copy link
Member

pauldix commented Jan 7, 2025

As part of #25654, #25618, and #25537, plugin authors will need the ability to query the database and get results back for use in their scripts. If should be part of the API pointer that gets handed to the various plugin entry point functions.

For now we can create a function that return rows like the kind yielded to the WAL plugins (see: https://github.com/influxdata/influxdb/blob/main/influxdb3_py_api/src/system_py.rs#L412-L459). Later we'll want to give users an option to return Arrow along with a dataframe API, but this should be enough to make something useful.

The function will by default query the database that a plugin is tied to (via its trigger) or take an optional parameter to specify a different database. They should take an optional PyDict with parameterized query arguments. So we have:

def query_rows(self, query: str, parameters: Optional[Dict[str, Any]] = None, database: Optional[str]) -> Row
@pauldix pauldix added the v3 label Jan 7, 2025
@pauldix pauldix self-assigned this Jan 7, 2025
pauldix added a commit that referenced this issue Jan 8, 2025
This ended up being a couple things rolled into one. In order to add a query API to the Python plugin, I had to pull the QueryExecutor trait out of server into a place so that the python crate could use it.

This implements the query API, but also fixes up the WAL plugin test CLI a bit. I've added a test in the CLI section so that it shows end-to-end operation of the WAL plugin test API and exercise of the entire Plugin API.

Closes #25757
pauldix added a commit that referenced this issue Jan 8, 2025
This ended up being a couple things rolled into one. In order to add a query API to the Python plugin, I had to pull the QueryExecutor trait out of server into a place so that the python crate could use it.

This implements the query API, but also fixes up the WAL plugin test CLI a bit. I've added a test in the CLI section so that it shows end-to-end operation of the WAL plugin test API and exercise of the entire Plugin API.

Closes #25757
pauldix added a commit that referenced this issue Jan 10, 2025
This ended up being a couple things rolled into one. In order to add a query API to the Python plugin, I had to pull the QueryExecutor trait out of server into a place so that the python crate could use it.

This implements the query API, but also fixes up the WAL plugin test CLI a bit. I've added a test in the CLI section so that it shows end-to-end operation of the WAL plugin test API and exercise of the entire Plugin API.

Closes #25757
pauldix added a commit that referenced this issue Jan 10, 2025
This ended up being a couple things rolled into one. In order to add a query API to the Python plugin, I had to pull the QueryExecutor trait out of server into a place so that the python crate could use it.

This implements the query API, but also fixes up the WAL plugin test CLI a bit. I've added a test in the CLI section so that it shows end-to-end operation of the WAL plugin test API and exercise of the entire Plugin API.

Closes #25757
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant