[
https://issues.apache.org/jira/browse/CALCITE-2769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16761390#comment-16761390
]
Chiradip Mandal commented on CALCITE-2769:
------------------------------------------
With a change in CsvEnumerator.java in the moveNext() method solves this
problem partially.
Instead of this:
{code:java}
current = rowConverter.convertRow(strings);
{code}
Using the following solves major issues. It does not throw
ArrayIndexOutOfBounds exceptions
{code:java}
try {
current = rowConverter.convertRow(strings);
} catch (Exception e) {
continue;
}
{code}
> CSV Adapter does not handle - Empty and malformed csv lines, space before or
> after comma
> ----------------------------------------------------------------------------------------
>
> Key: CALCITE-2769
> URL: https://issues.apache.org/jira/browse/CALCITE-2769
> Project: Calcite
> Issue Type: Bug
> Components: csv-adapter
> Affects Versions: 1.18.0
> Reporter: Chiradip Mandal
> Assignee: Julian Hyde
> Priority: Major
> Fix For: next
>
>
> File: org.apache.calcite.adapter.csv.CsvEnumerator.java in example folder did
> not handle CSV with space between delimiter i.e."," and also did not handle
> empty lines or malformed lines in the middle of the file or to the end. The
> sqlline crashes is there is an empty line with
> java.lang.ArrayIndexOutOfBoundsException.
>
> java.lang.ArrayIndexOutOfBoundsException: 1
> at
> org.apache.calcite.adapter.csv.CsvEnumerator$ArrayRowConverter.convertNormalRow(CsvEnumerator.java:347)
> at
> org.apache.calcite.adapter.csv.CsvEnumerator$ArrayRowConverter.convertRow(CsvEnumerator.java:339)
> at
> org.apache.calcite.adapter.csv.CsvEnumerator$ArrayRowConverter.convertRow(CsvEnumerator.java:317)
> at
> org.apache.calcite.adapter.csv.CsvEnumerator.moveNext(CsvEnumerator.java:204)
> at
> org.apache.calcite.linq4j.EnumerableDefaults$10$1.moveNext(EnumerableDefaults.java:1878)
> at
> org.apache.calcite.linq4j.EnumerableDefaults$10$1.moveNext(EnumerableDefaults.java:1878)
> at
> org.apache.calcite.linq4j.TransformedEnumerator.moveNext(TransformedEnumerator.java:35)
> at org.apache.calcite.linq4j.Linq4j$EnumeratorIterator.next(Linq4j.java:684)
> at org.apache.calcite.avatica.util.IteratorCursor.next(IteratorCursor.java:46)
> at org.apache.calcite.avatica.AvaticaResultSet.next(AvaticaResultSet.java:217)
> at sqlline.IncrementalRows.hasNext(IncrementalRows.java:73)
> at sqlline.TableOutputFormat.print(TableOutputFormat.java:38)
> at sqlline.SqlLine.print(SqlLine.java:1719)
> at sqlline.Commands.execute(Commands.java:949)
> at sqlline.Commands.sql(Commands.java:882)
> at sqlline.SqlLine.dispatch(SqlLine.java:725)
> at sqlline.SqlLine.begin(SqlLine.java:540)
> at sqlline.SqlLine.start(SqlLine.java:264)
> at sqlline.SqlLine.main(SqlLine.java:195)
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)