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

added table comment to Table Info in SQLDatabase #11774

Merged
merged 3 commits into from
Mar 12, 2024

Conversation

sumanmichael
Copy link
Contributor

Description

In this PR, I've enhanced the get_single_table_info method in the SQLDatabase class. Now, apart from returning table's column and foreign key information, it also fetches and includes the table's comment if it exists. The comment is retrieved using the get_table_comment method from the _inspector object and appended to the output string. This additional information will provide more context about the table when this method is used.

Fixes #11075

Version Bump?

Did I bump the version in the pyproject.toml file of the package I am updating? (Except for the llama-index-core package)

  • Yes
  • No

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Added new unit/integration tests
  • Added new notebook (that tests end-to-end)
  • I stared at the code and made sure it makes sense

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added Google Colab support for the newly added notebooks.
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran make format; make lint to appease the lint gods

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 8, 2024
Copy link
Contributor

@hatianzhang hatianzhang left a comment

Choose a reason for hiding this comment

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

lgtm

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 8, 2024
@hatianzhang
Copy link
Contributor

@sumanmichael could you help fix the unit tests

@sumanmichael
Copy link
Contributor Author

sumanmichael commented Mar 9, 2024

If a SQL dialect did not support table comments, a NotImplementedError would be raised. Ref

Handled with a try-except. This clears the unit tests

@hatianzhang hatianzhang merged commit 8490483 into run-llama:main Mar 12, 2024
8 checks passed
bdonkey added a commit to bdonkey/gpt_index that referenced this pull request Mar 12, 2024
* main:
  add retries for openai LLM rate limit errors (run-llama#11867)
  Fix stream chat param error in CondenseQuestionChatEngine (run-llama#11856)
  Add logprobs field to `CompletionResponse` (run-llama#11855)
  Google readers integrations doc and drive updates (run-llama#11724)
  Adds llamafile support for local LLM and embeddings (run-llama#11709)
  Add QueryUnderstandingAgent LlamaPack (run-llama#11558)
  Split Google docs on headings (run-llama#11535)
  add baidu vectordb as vector store (run-llama#11494)
  [Feature Request]: add PowerPoint support to Confluence reader run-llama#10592 (run-llama#11454)
  add modelscope llm support (run-llama#11270)
  Add cohere command-R model (run-llama#11852)
  Fixed some gramatical mistakes  (run-llama#11840)
  fix obj insert_nodes (run-llama#11836)
  added table comment to Table Info in SQLDatabase (run-llama#11774)
  Fixes for add and delete Methods in LanceDBVectorStore (run-llama#11825)
  add support for open-mixtral-8x7b (run-llama#11792)
  Adds new LabelledSimpleDataset (llama-dataset) (run-llama#11805)
  Fix Cohere Embeddings issue run-llama#11820 (run-llama#11822)
  Update verifying connection (run-llama#11821)
  bump mistralai deps (run-llama#11819)
Izukimat pushed a commit to Izukimat/llama_index that referenced this pull request Mar 29, 2024
* added table comment in sql query

* handle SQL dialects without comment support

* typo in comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Question]: For SQLTableRetrieverQueryEngine, there is no table comment?
2 participants