nilotpaldhar2004 commited on
Commit
49d3371
·
unverified ·
1 Parent(s): 471250f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -1
app.py CHANGED
@@ -100,7 +100,7 @@ def generate_sql(question: str, schema: str) -> str:
100
  if re.search(r'show.*(all|every).*row|all.*row|select all', q):
101
  return f'SELECT * FROM {quoted} LIMIT 50'
102
  if re.search(r'average|avg', q) and col_match:
103
- num_col = next((c for c in col_match if re.search(r'num|price|val|amt|count|qty|sal|rev|cost|pm|aqi|no|co|so|o3', c, re.I)), col_match[1] if len(col_match) > 1 else col_match[0])
104
  return f'SELECT AVG("{num_col}") FROM {quoted}'
105
  if re.search(r'unique|distinct', q) and col_match:
106
  return f'SELECT COUNT(DISTINCT "{col_match[0]}") FROM {quoted}'
 
100
  if re.search(r'show.*(all|every).*row|all.*row|select all', q):
101
  return f'SELECT * FROM {quoted} LIMIT 50'
102
  if re.search(r'average|avg', q) and col_match:
103
+ num_col = next((c for c in col_match if re.search(r'pm|aqi|no|co|so|o3|benzene|toluene|xylene', c, re.I)), col_match[2])
104
  return f'SELECT AVG("{num_col}") FROM {quoted}'
105
  if re.search(r'unique|distinct', q) and col_match:
106
  return f'SELECT COUNT(DISTINCT "{col_match[0]}") FROM {quoted}'