-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_date_between.py
More file actions
39 lines (32 loc) · 1015 Bytes
/
test_date_between.py
File metadata and controls
39 lines (32 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from text2sql_engine import Text2SQLEngine
engine = Text2SQLEngine(use_llm=False)
sql = """SELECT 'AWS' as provider, regionname, SUM(billedcost) as cost
FROM aws_cost_usage
WHERE billingperiodstart BETWEEN date('now', '-7 days') AND date('now')
GROUP BY regionname
UNION ALL
SELECT 'Azure' as provider, regionname, SUM(billedcost) as cost
FROM azure_cost_usage
WHERE billingperiodstart BETWEEN date('now', '-7 days') AND date('now')
GROUP BY regionname
ORDER BY cost DESC
LIMIT 5"""
print("ORIGINAL SQL:")
print(sql)
print("\n" + "="*80 + "\n")
fixed, warn = engine._detect_and_fix_date_issues(sql)
print("FIXED SQL:")
print(fixed)
print("\n" + "="*80 + "\n")
if warn:
print("WARNING:", warn)
print("\n" + "="*80 + "\n")
# Test execution
print("EXECUTING...")
result = engine.db.execute_query(fixed)
if result is not None:
print(f"SUCCESS: {len(result)} rows returned")
if len(result) > 0:
print(result)
else:
print("FAILED: No results")