What is the Best Approach to Text to Sql Query Generation?

Hello, everyone.
I’ve been searching possible ways to leverage chat-GPT for text to sql query generation and possibilities have been narrowed down to three ways; LlamaIndex, LangChain, and fine-tuning. There are some articles and blog posts that explain how those three approaches can be coordinated with Chat-GPT capabilities to generate sql query from natural language. However, they showcase a small dataset with at most ten tables and a generated query is relatively a simple one.
My workplace uses MySQL with 60 tables and 640 columns and an expected sql query to be generated can be as complex as follows.

SELECT Users,hostName, Users.email
FROM Users
SELECT Places.naviId, COUNT(*) AS roomCount
FROM Places
SELECT Itineraries.roomId
FROM Itineraries
WHERE Itineraries.createdAt >= ‘2022-01-01’ AND 'Itineraries.createdAt <= ‘2022-12-31’
) AS itineraryRoomIds ON Places.id = itineraryRoomIds.roomId
WHERE Places.type IN (‘world’, ‘event’)
AND (itineraryRoomIds.roomId IS NULL OR itineraryRoomIds.roomId = Placesid)
GROUP BY Places.naviId
) AS roomCounts ON Usersid = roomCountsnaviID
WHERE roomCounts.roomCount IS NULL AND hostName IS NOT NULL AND UsersisAdmin = 1;

Which way would reasonably be expected to produce the best query in my situation?

1 Like