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

feat: DuckDB connection as a state management instance #32

Closed
wants to merge 2 commits into from

Conversation

sanjibansg
Copy link
Contributor

This PR modifies the way we use the DuckDB instance for executing queries and parsing SQL queries to Substrait plans. We were using global variables, which aren't recommended, instead, it would be better to use a state management instance.

@sanjibansg sanjibansg linked an issue Jun 24, 2023 that may be closed by this pull request
except Exception as e:
logger.info(
"Healthcheck failed for DuckDB"
"Initializing new connection object. Details: ",
Copy link

Choose a reason for hiding this comment

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

This comment makes it seems like we try to initialize a new connection if the health check failed. That doesn't seem to be the case here right?

self.connection.load_extension("substrait")
self.connection.install_extension("tpch")
self.connection.load_extension("tpch")
self.connection.execute(query=schema_lineitem)
Copy link

Choose a reason for hiding this comment

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

Creating the table doesn't seem like it belongs in the connect method? maybe have a separate one just for the table creation?

)
finally:
return status
def check(self):
Copy link

Choose a reason for hiding this comment

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

It might make more sense to have the separate method for table creation and doing the health check as part of that? And then store that health status in a class variable? What do you think?

@EpsilonPrime EpsilonPrime requested review from EpsilonPrime and removed request for westonpace September 26, 2023 00:48
@EpsilonPrime
Copy link
Contributor

@sanjibansg How do you want to proceed with this PR?

@sanjibansg
Copy link
Contributor Author

closing this, since this is a requirement for the custom schema functionality, and has been implemented in the respective PR #51

@sanjibansg sanjibansg closed this Oct 29, 2023
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.

DuckDB connection as a state management instance
3 participants