Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Projection Aliases #18

Open
niryarden opened this issue Sep 27, 2023 · 2 comments
Open

Support Projection Aliases #18

niryarden opened this issue Sep 27, 2023 · 2 comments

Comments

@niryarden
Copy link

Problem:

Adding an alias to a projection in the SELECT clause is a pretty standard syntax:

SELECT count(*) AS table_size FROM Table

However, the evaluator breaks when trying to parse this kind of query.

Reproduce:

I went to the gold.txt file and changed the 3rd row from

SELECT Country FROM AIRLINES WHERE Airline  =  "JetBlue Airways"	flight_2

to

SELECT Country AS my_c FROM AIRLINES WHERE Airline  =  "JetBlue Airways"	flight_2`

When running

python evaluation.py --gold evaluation_examples/gold.txt --pred evaluation_examples/predict.txt --db database --etype match --plug_value --table tables.json

parse_sql crashed with:

AssertionError: Error col: as

thrown from parse_col when searching for the the not existing 'as' column in the schema.

@sorgfresser
Copy link

The same happens upon using strftime in the select. I was able to produce AssertionError: Error col: strftime using the test set of EHRSQL.
With the query

select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 85169 and admissions.dischtime is not null order by admissions.admittime asc limit 1

This is somewhat more niche as strftime is SQLite syntax, but since Spider uses SQLite I was a bit surprised that this error occurred.

@sorgfresser
Copy link

sorgfresser commented Jun 15, 2024

I adapted the whole test suite to use sqlglot in my fork now, so I can use strftime and projection aliases as well. Maybe it's also interesting for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants