Find answers from the community

Updated last year

SQL

At a glance

The community member is using the SQLTableRetrieverQueryEngine and following a demo, but is facing an issue where they have to pass the exact keyword for the value, e.g. 'How many orders with status Cancelled?' works but 'How many orders with status cancelled?' doesn't. The community members suggest that this is because the SQL formation is checking for status=cancelled, and there are no records for this label. One solution proposed is to insert the labels in the database in lowercase, and before passing the query, convert it to lowercase using query.lower(). Another community member questions whether this would also uncapitalize supposedly capitalized labels, but the original community member believes that since all the labels are in lowercase, there won't be any issues.

Useful resources
Using SQLTableRetrieverQueryEngine, Im following this demo: https://docs.llamaindex.ai/en/stable/examples/index_structs/struct_indices/SQLIndexDemo.html
the problem is I have to pass the exact keyword for the value, for example 'How many orders with status cancelled?' doesnt work but 'How many orders with status Cancelled?' works.
How can I improve/make it more generic
Attachment
image.png
W
T
4 comments
During SQL formation it is checking for status=cancelled maybe that's why it is failing as there are no records for this label.

One way would be You could insert the labels in the db in smallcase and before passing your query you pass it like query.lower() to the query_engine
won't this return supposedly capitalized labels as uncap too ? πŸ€”
Yeah, but since all the labels are in smallcase, there won't be any issue in there I guess!
Thanks, this method should do for now
Add a reply
Sign up and join the conversation on Discord