Paul Rogers created DRILL-7303:
----------------------------------

             Summary: Filter record batch does not handle zero-length batches
                 Key: DRILL-7303
                 URL: https://issues.apache.org/jira/browse/DRILL-7303
             Project: Apache Drill
          Issue Type: Bug
    Affects Versions: 1.16.0
            Reporter: Paul Rogers
            Assignee: Paul Rogers


Testing of the row-set-based JSON reader revealed a limitation of the Filter 
record batch: if an incoming batch has zero records, the length of the 
associated SV2 is left at -1. In particular:

{code:java}
public class SelectionVector2 implements AutoCloseable {
  // Indicates actual number of rows in the RecordBatch
  // container which owns this SV2 instance
  private int batchActualRecordCount = -1;
{code}

Then:

{code:java}
public abstract class FilterTemplate2 implements Filterer {
  @Override
  public void filterBatch(int recordCount) throws SchemaChangeException{
    if (recordCount == 0) {
      outgoingSelectionVector.setRecordCount(0);
      return;
    }
{code}

Notice there is no call to set the actual record count. The solution is to 
insert one line of code:

{code:java}
    if (recordCount == 0) {
      outgoingSelectionVector.setRecordCount(0);
      outgoingSelectionVector.setBatchActualRecordCount(0); // <-- Add this
      return;
    }
{code}

Without this, the query fails with an error due to an invalid index of -1.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to