@@ -1492,7 +1492,8 @@ public ColumnIndexStore getColumnIndexStore(int blockIndex) {
14921492 /**
14931493 * Computes the {@link RowRanges} within the given row group that may pass the configured filter
14941494 * (set via {@link ParquetReadOptions} or {@link ParquetInputFormat#setFilterPredicate}). If no
1495- * filter is configured, returns a {@link RowRanges} covering all rows in the row group.
1495+ * filter is configured, returns a {@link RowRanges} covering all rows in the row group. If the
1496+ * row group has no rows, returns {@link RowRanges#EMPTY}.
14961497 *
14971498 * <p>This computation is metadata-only: it consults each filter-referenced column's column
14981499 * index from the file footer; no column data is read from disk. The result can be passed to
@@ -1501,10 +1502,20 @@ public ColumnIndexStore getColumnIndexStore(int blockIndex) {
15011502 *
15021503 * @param blockIndex the row group (block) index
15031504 * @return row ranges within the block that may pass the configured filter
1505+ * @throws IllegalArgumentException if {@code blockIndex} is out of range
15041506 */
15051507 public RowRanges getRowRanges (int blockIndex ) {
1508+ if (blockIndex < 0 || blockIndex >= blocks .size ()) {
1509+ throw new IllegalArgumentException (String .format (
1510+ "Invalid block index %s, the valid block index range are: [%s, %s]" ,
1511+ blockIndex , 0 , blocks .size () - 1 ));
1512+ }
1513+ long rowCount = blocks .get (blockIndex ).getRowCount ();
1514+ if (rowCount == 0L ) {
1515+ return RowRanges .EMPTY ;
1516+ }
15061517 if (!FilterCompat .isFilteringRequired (options .getRecordFilter ())) {
1507- return RowRanges .createSingle (blocks . get ( blockIndex ). getRowCount () );
1518+ return RowRanges .createSingle (rowCount );
15081519 }
15091520 RowRanges rowRanges = blockRowRanges .get (blockIndex );
15101521 if (rowRanges == null ) {
0 commit comments