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 duckdb.raw_query function #203

Merged
merged 1 commit into from
Sep 24, 2024
Merged

Add duckdb.raw_query function #203

merged 1 commit into from
Sep 24, 2024

Conversation

JelteF
Copy link
Collaborator

@JelteF JelteF commented Sep 23, 2024

For upcoming features, specifically MotherDuck support it is quite useful to be able to send raw queries to DuckDB to inspect the current state of the database. Such as DESCRIBE or SELECT * FROM duckdb_tables(); or even queries to debug the our current SECRET support. This adds a small helper function to do this. The result is shown in a NOTICE message instead of actually returning them as rows, so that there's no need for the AS (some_column int, some_other_column text) stuff. We'll probably want a function that returns actual rows too for use in scripts, but this is a bit easier to use for debugging at the moment. It's specifically named duckdb.raw_query, so we can use duckdb.query for the function that actually returns rows.

For upcoming features, specifically MotherDuck support it is quite
useful to be able to send raw queries to DuckDB to inspect the current
state of the database. Such as `DESCRIBE` or `SELECT * FROM
duckdb_tables();` or even queries to debug the our current `SECRET`
support. This adds a small helper function to do this. The result is
shown in a NOTICE message instead of actually returning them as rows, so
that there's no need for the `AS (some_column int, some_other_column
text)` stuff. We'll probably want a function that returns actual rows
too for use in scripts, but this is a bit easier to use for debugging at
the moment. It's specifically named `duckdb.raw_query`, so we can use
`duckdb.query` for the function that actually returns rows.
@JelteF JelteF merged commit 5253bdf into main Sep 24, 2024
3 checks passed
@JelteF JelteF deleted the raw-query branch September 24, 2024 18:43
@wuputah
Copy link
Collaborator

wuputah commented Sep 24, 2024

CI is failing on main / subsequent PRs due to a table oid mismatch.

--- /home/runner/work/pg_duckdb/pg_duckdb/duckdb/test/regression/expected/raw_query.out	2024-09-24 18:56:04.958433346 +0000
+++ /home/runner/work/pg_duckdb/pg_duckdb/duckdb/test/regression/results/raw_query.out	2024-09-24 18:56:34.711724950 +0000
@@ -13,7 +13,7 @@
 NOTICE:  result: database_name	database_oid	schema_name	schema_oid	table_name	table_oid	comment	tags	internal	temporary	has_primary_key	estimated_size	column_count	index_count	check_constraint_count	sql	
 VARCHAR	BIGINT	VARCHAR	BIGINT	VARCHAR	BIGINT	VARCHAR	MAP(VARCHAR, VARCHAR)	BOOLEAN	BOOLEAN	BOOLEAN	BIGINT	BIGINT	BIGINT	BIGINT	VARCHAR	
 [ Rows: 1]
-memory	1148	main	1150	t	1266	NULL	{}	false	false	false	0	1	0	0	CREATE TABLE t(a INTEGER);
+memory	1148	main	1150	t	1269	NULL	{}	false	false	false	0	1	0	0	CREATE TABLE t(a INTEGER);

@JelteF
Copy link
Collaborator Author

JelteF commented Sep 24, 2024

Ugh, lets remove the test for now then.

@JelteF
Copy link
Collaborator Author

JelteF commented Sep 24, 2024

See #214

JelteF added a commit that referenced this pull request Sep 24, 2024
This quickly removes a test that is now failing in CI. In another PR
I'll try to add a non-flaky test back, but this removes the immediate
problem.

The problematic test was added in #203
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants