ryanzhumich / editsql

MIT License
202 stars 68 forks source link

getting actual values in predicted SQL queries #27

Open trangel opened 3 years ago

trangel commented 3 years ago

Hello, I find that all the values in the input questions are replaced by 1 in the SQL query.

For example, if my input is (these examples are just illustrative, not real):

"Get the top 10 samples in column_x" This top 10 query is translated to "SELECT column_x FROM table ORDER BY column_x DESC LIMIT 1" So it replaced top 10 by top 1

Also in conditions: "List a column X where column Y < 0.1" Is translated to "SELECT column_x FROM table WHERE column_y < 1" Again 0.1 is replaced by 1

Do you have a mechanism to fix this?

ghost commented 2 years ago

yes getting the same issue it is replacing value by 1 and _EOS by whitespace

select AirportCode, AirportName from airports where City = 1 here city value is 1 as it is hardcoded in code to replace all values with 1

her is the code from postprocessing.py def postprocess_one(pred_sql, schema): pred_sql = pred_sql.replace('group_by', 'group by').replace('order_by', 'order by').replace('limit_value', 'limit 1').replace('_EOS', '').replace(' value ',' 1 ').replace('distinct', '').strip(',').strip() if pred_sql.endswith('value'): pred_sql = pred_sql[:-len('value')] + '1'

ghost commented 2 years ago

this out is received in output_temp.txt, is there a way to get correct SQL queries