MCPcopy Create free account
hub / github.com/caesarHQ/textSQL / testQueryWorks

Function testQueryWorks

api/app/api/chronjobs/test_homepage_queries.py:32–63  ·  view source on GitHub ↗
(query, scope)

Source from the content-addressed store, hash-verified

30
31# go thru and test that each of the generate tables -> generate SQL works
32def testQueryWorks(query, scope):
33 global good, bad, attempted, results
34 print('trying ', query)
35 attempted.append(query)
36 try:
37 payload = {
38 "natural_language_query": query,
39 "scope": scope
40 }
41 res = queryTextToTables(payload)
42 print('tables: ', res['table_names'])
43 payload = {
44 "table_names": res['table_names'],
45 "natural_language_query": query,
46 "scope": scope
47 }
48 res2 = queryTextToSQL(payload)
49 print(len(res2['result']['column_names']), ' columns')
50 print(len(res2['result']['results']), 'rows')
51 print('SQL query: \n', res2['sql_query'])
52 print('\n \n---- \n \n')
53 good.append(query)
54 results.append({'q': query,
55 'columns': len(res2['result']['column_names']),
56 'rows': len(res2['result']['results']),
57 'sql': res2['sql_query']
58 })
59
60
61 except Exception as e:
62 print('Failure!', str(e))
63 bad.append({'q': query, 'e':str(e)})
64
65# test the SF homepage queries
66if 'SF' in scope:

Callers 1

Calls 2

queryTextToTablesFunction · 0.85
queryTextToSQLFunction · 0.85

Tested by

no test coverage detected