Skip to content

Conversation

davidhaller
Copy link

Apache Drill is able to perform queries like this on CSV files:

select columns[0], columns[1] from dfs.`/tmp/drill/test.csv`

JSqlParser could not parse column identifiers with an array index, so I modified the grammar. I'm not sure that I did everything right, as I never worked with JavaCC before. Tests still pass, and the debug output says that columns[0] and columns[1] were recognized as identifiers.

@coveralls
Copy link

coveralls commented Dec 11, 2016

Coverage Status

Coverage decreased (-0.1%) to 84.108% when pulling 9afb380 on davidhaller:master into 66e44c9 on JSQLParser:master.

@wumpz
Copy link
Member

wumpz commented Dec 11, 2016

The problem I see is, that there is already some kind of array indexing. Additionally the array index will be part of an identifier, which is IMHO not correct.

@davidhaller
Copy link
Author

davidhaller commented Dec 11, 2016

Apache Drill names columns from CSV files columns[0], columns[1] and so on which are usually renamed and casted to the desired data type, like this:

select cast(columns[0] as int) as user_id, columns[1] as username,
cast(columns[2] as timestamp) as registration_date
from `users.csv`

PostgreSQL, for example, has arrays similar like this which can be used within the "select" clause (https://www.postgresql.org/docs/9.6/static/arrays.html). If array support already exists in JSQLParser, what do I need to change to allow array access within "select"?

@manticore-projects
Copy link
Contributor

Obsolete, since it is working fine with JSQLParser 4.7. You can test it online here.

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

Successfully merging this pull request may close these issues.

4 participants