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

SQL validation: how to query with a taxon order #358

Open
MortenHofft opened this issue Nov 1, 2024 · 2 comments
Open

SQL validation: how to query with a taxon order #358

MortenHofft opened this issue Nov 1, 2024 · 2 comments

Comments

@MortenHofft
Copy link
Member

SELECT \"kingdom\", \"kingdomkey\", COUNT(*) AS occurrences FROM occurrence WHERE countryCode = 'PL' GROUP BY \"kingdom\", \"kingdomkey\"

works fine, but below fails with the error From line 1, column 8 to line 1, column 14: Column 'order' not found in any table

{
  "format": "SQL_TSV_ZIP", 
  "sql": "SELECT \"order\", \"orderkey\", COUNT(*) AS occurrences FROM occurrence WHERE countryCode = 'PL' GROUP BY \"order\", \"orderkey\"" 
}

I assume it is related to order being a reserved word. I had thought quoting would do it, but clearly not.

I have double quoted based on https://techdocs.gbif.org/en/data-use/data-cubes

YEAR(…) (or year(…)) and MONTH(…) are SQL functions, so we must quote the name of the columns as "year" and "month" using double quotes.

@MortenHofft
Copy link
Member Author

I got it working. It is order_ which i discovered in https://api.gbif.org/v1/occurrence/download/describe/sql
It might be worth highlighting in the documentation that order is different from everything else. Ideally even in the error response.

@MattBlissett
Copy link
Member

It's fixed in the UAT version, and in the UAT documentation.

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