Skip to content

NEM-321 Sql query execution#112

Open
annav1asova wants to merge 1 commit intomainfrom
NEM-321
Open

NEM-321 Sql query execution#112
annav1asova wants to merge 1 commit intomainfrom
NEM-321

Conversation

@annav1asova
Copy link
Collaborator

No description provided.

def run_sql(
self, file_config: T, sql: str, params: list[Any] | None = None, read_only: bool = True
) -> SqlExecutionResult:
return self._introspector.run_sql(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: This method doesn't really belong in the introspector

I'm not sure it's worth it to take it out though: you'd need to refactor a bit to have a class executing SQL (including our SQL introspection queries) that is used by the Introspector



@runtime_checkable
class SqlRunnablePlugin[T](BuildDatasourcePlugin[T], Protocol):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This feel like it should be its own independent protocol rather than extending BuildDatasourcePlugin

And plugins would keep on implementing BuildDatasourcePlugin but they would also implement SqlRunnablePlugin on top

I'm not fully sure how well it would work with the generics since we would want it to be the same for both the BuildDatasourcePlugin and the SqlRunnablePlugin 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or maybe it would be easier for the run_sql to always be part of BuildDatasourcePlugin but with a default implementation throwing an exception. And instead of casting, we're always calling the method and catching the NotSupported exception

datasource_ids: list[DatasourceId] | None = None,
) -> list[ContextSearchResult]:
"""Search in the avaialable context for the closest matches to the given text.
"""Search in the available context for the closest matches to the given text.
Copy link
Collaborator

Choose a reason for hiding this comment

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

🙏

def _apply(plugins_map):
mocker.patch(
"databao_context_engine.plugin_loader.load_plugins",
new=lambda: plugins_map,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm pretty sure the DatabaoContextPluginLoader takes an optional map of plugins (that was added specifically for tests to avoid patching)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Since you're testing the databao_context_engine directly, I would move this file directly in tests

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