Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-7303

Filter record batch does not handle zero-length batches

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 1.16.0
    • None
    • None
    • None

    Description

      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:

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

      Then:

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

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

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

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

      Attachments

        Issue Links

          Activity

            People

              Paul.Rogers Paul Rogers
              Paul.Rogers Paul Rogers
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: