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

Fix: configure duckdb with connector_config settings. #2240

Merged
merged 2 commits into from
Mar 12, 2024

Conversation

crericha
Copy link
Contributor

@crericha crericha commented Mar 8, 2024

duckdb.connect does not properly parse config dicts that are passed into it, so instead set each config setting directly in duckdb when we init the cursor.

@crericha crericha requested a review from eakmanrq March 8, 2024 23:45
@seandavi
Copy link

seandavi commented Mar 9, 2024

Thx, @crericha, for the quick fix. A checkout does fix the parsing issue from what I can tell. I'm not yet able to read from s3 due to a new error, but I'll file something once I narrow down the problem.

@@ -150,6 +146,12 @@ def init(cursor: duckdb.DuckDBPyConnection) -> None:
except Exception as e:
raise ConfigError(f"Failed to load extension {extension}: {e}")

for field, setting in self.connector_config.items():
try:
cursor.execute(f"SET {field} = '{setting}'")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is value always a string literal?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a list of settings. I cannot confirm that all of these settings can be changed using SET {field}, but there are definitely other types included in this list:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mimics dbt's behavior.

@crericha crericha merged commit 1c1baa5 into main Mar 12, 2024
10 checks passed
@crericha crericha deleted the duckdb-connector-config branch March 12, 2024 04:25
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.

3 participants