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

Please add support for database views in SQLDatabase #9748

Closed
johanteekens opened this issue Dec 29, 2023 · 6 comments
Closed

Please add support for database views in SQLDatabase #9748

johanteekens opened this issue Dec 29, 2023 · 6 comments
Labels
enhancement New feature or request triage Issue needs to be triaged/prioritized

Comments

@johanteekens
Copy link

Feature Description

current situation: SQLDatabase(engine, include_tables=["city_stats"])
obj_index = ObjectIndex.from_objects(table_schema_objs,table_node_mapping,VectorStoreIndex,)
query_engine = SQLTableRetrieverQueryEngine(sql_database, obj_index.as_retriever(),)

preferred new option: SQLDatabase(engine, include_databaseobjects=["city_stats","myview1","mytable1","myview2"])

Reason

My database tables are virtually unreadable for anything, but I can create views on top of my tables, that explain what is it is, convert julian dates, do lookups etc etc. I can't change the tables because that would break my application, but I can add views.

Value of Feature

SQLTableRetrieverQueryEngine becomes more flexible and powerful.

please........ ;-)

@johanteekens johanteekens added enhancement New feature or request triage Issue needs to be triaged/prioritized labels Dec 29, 2023
Copy link

dosubot bot commented Dec 29, 2023

🤖

That sounds like a great idea! Adding support for database views in SQLDatabase would definitely make the system more flexible and powerful. Your suggestion to include database objects like views along with tables is a valuable enhancement. I encourage you to go ahead and create a pull request with your proposed changes. Your contribution will be appreciated by the community and the maintainers will review it. Thank you for your willingness to improve LlamaIndex!


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@logan-markewich
Copy link
Collaborator

I have no idea how table views would work the sqlalchemy, but I encourage you to take a stab at a PR if you are up to it.

The SQLDatabase code is here

@johanteekens
Copy link
Author

Looking at sql_wrapper.py, It looks like someone already build in support.

In sql_wrapper.py there is this bool: view_support: bool = False, it looks like it's as simple as toggling it.

@logan-markewich
Copy link
Collaborator

Give it a shot, see if it works 🫡

@johanteekens
Copy link
Author

Created pull request #9802

Works perfectly fine for me at least

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Apr 2, 2024
Copy link

dosubot bot commented Apr 2, 2024

Hi, @johanteekens,

I'm helping the LlamaIndex team manage our backlog and am marking this issue as stale. It looks like you requested adding support for database views in SQLDatabase to enhance the flexibility and power of the SQLTableRetrieverQueryEngine. You've already created pull request #9802, stating that it works perfectly fine for you.

Could you please confirm if this issue is still relevant to the latest version of the LlamaIndex repository? If it is, please let the LlamaIndex team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your contribution! If you have any further questions or need assistance, feel free to reach out.

I'm Dosu

@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 9, 2024
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage Issue needs to be triaged/prioritized
Projects
None yet
Development

No branches or pull requests

2 participants