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: SnoopyView to support option for passing schema #82

Open
PatrykWyzgowski opened this issue Aug 12, 2024 · 0 comments
Open

feat: SnoopyView to support option for passing schema #82

PatrykWyzgowski opened this issue Aug 12, 2024 · 0 comments
Labels
feature New feature or request

Comments

@PatrykWyzgowski
Copy link
Contributor

PatrykWyzgowski commented Aug 12, 2024

Feature description

Add SnoopyView which is a type of View with loosend db-ally assumptions and runs user-defined method for accessing a schema.

Motivation

The db-ally usage allows for defining filters and aggregations but they bump into significant trade-off: genericness vs performance.
E.g. preferable (in terms of UX) implementation of an aggregation would be as follows:

@decorators.view_aggregation()
def count_by_column(self, filtered_query: sqlalchemy.Select, column_name: str) -> sqlalchemy.Select:
        select = sqlalchemy.select(getattr(filtered_query.c, column_name),
                                   sqlalchemy.func.count(filtered_query.c.name).label("count")) \
            .group_by(getattr(filtered_query.c, column_name))
        return select

Please not that such implementation delegates the column name resolution to LLM which can impact the performance (LLM can poorly guess the column name).

To address the performance issue one can implement a method with the name of the column to be used directly:

@decorators.view_aggregation()
def count_by_university(self, filtered_query: sqlalchemy.Select) -> sqlalchemy.Select:
        select = sqlalchemy.select(filtered_query.c.university),
                                   sqlalchemy.func.count(filtered_query.c.name).label("count")) \
            .group_by(filtered_query.c.university)
        return select

This creates a risk of creating vast amount of boilerplate assuming general-purpose View.
Some db-ally (or Text2SQL) user might prefer generic filters/aggregations usage and boost performance in favor of decoupling the database structure from the prompt. Such nosy SnoopyView might ask implicitly for the structure to use it in a prompt or inject additional few-shot examples.

Additional context

NosyView was initially considered but SnoopyView synonym additionally refers to a dog used together with the library name 🦮.

@PatrykWyzgowski PatrykWyzgowski added the feature New feature or request label Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant