github.com/parquet-go/parquet-go@v0.20.0/scan_test.go (about)

     1  package parquet_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/parquet-go/parquet-go"
     7  )
     8  
     9  func TestScanRowReader(t *testing.T) {
    10  	rows := []parquet.Row{
    11  		{parquet.Int64Value(0)},
    12  		{parquet.Int64Value(1)},
    13  		{parquet.Int64Value(2)},
    14  		{parquet.Int64Value(3)},
    15  		{parquet.Int64Value(4)},
    16  	}
    17  
    18  	want := []parquet.Row{
    19  		{parquet.Int64Value(0)},
    20  		{parquet.Int64Value(1)},
    21  		{parquet.Int64Value(2)},
    22  	}
    23  
    24  	reader := parquet.ScanRowReader(&bufferedRows{rows: rows},
    25  		func(row parquet.Row, _ int64) bool {
    26  			return row[0].Int64() < 3
    27  		},
    28  	)
    29  
    30  	writer := &bufferedRows{}
    31  	_, err := parquet.CopyRows(writer, reader)
    32  	if err != nil {
    33  		t.Fatal(err)
    34  	}
    35  
    36  	assertEqualRows(t, want, writer.rows)
    37  }