0
votes

I have a problem in querying a CSV (with header) file using Drill. If I run the following code:

SELECT Bid, Last FROM table(dfs.`/data/bb_20020201.csv` (type => 'text', fieldDelimiter => ',', extractHeader => true));

I got an error code corresponding to the word "Last". If I query another column instead of Last everything works nice. I think the problem is because Last is also a SQL command.

I would really appreciate any help on this issue.

1
Did below answer resolved your issue ? Please let us know. - Sorabh

1 Answers

1
votes

It seems Last is reserved keyword in Drill. Enclose it in a back-ticks:

SELECT Bid, `Last` FROM ...

https://drill.apache.org/docs/lexical-structure/#identifiers

Or change identifier quotes to double quotes or brackets if you need: https://drill.apache.org/docs/lexical-structure/#identifier-quotes

If it helps you, you can create a Jira ticket to add Last to reserved keywords table: https://drill.apache.org/docs/reserved-keywords/