luoyuxia commented on PR #138:
URL: https://github.com/apache/paimon-rust/pull/138#issuecomment-4065887989

   I already verify it in my own paimon-rust fork. See 
https://github.com/luoyuxia/paimon-rust/releases/tag/bindings%2Fgo%2Fv0.1.2
   Verified with the following code:
   ```
   package main
   
   import (
        "errors"
        "fmt"
        "io"
        "log"
        "os"
   
        "github.com/apache/arrow-go/v18/arrow/array"
        paimon "github.com/luoyuxia/paimon-rust/bindings/go"
   )
   
   // TIP <p>To run your code, right-click the code and select <b>Run</b>.</p> 
<p>Alternatively, click
   // the <icon src="AllIcons.Actions.Execute"/> icon in the gutter and select 
the <b>Run</b> menu item from here.</p>
   func main() {
        warehouse := os.Getenv("PAIMON_TEST_WAREHOUSE")
        if warehouse == "" {
                warehouse = 
"/Users/yuxia/Projects/rust-projects/paimon-rust/dev/paimon-warehouse"
        }
   
        catalog, err := paimon.NewFileSystemCatalog(warehouse)
        if err != nil {
                log.Fatalf("Failed to create catalog: %v", err)
        }
        defer catalog.Close()
   
        table, err := catalog.GetTable(paimon.NewIdentifier("default", 
"simple_log_table"))
        if err != nil {
                log.Fatalf("Failed to get table: %v", err)
        }
        defer table.Close()
   
        rb, err := table.NewReadBuilder()
        if err != nil {
                log.Fatalf("Failed to create read builder: %v", err)
        }
        defer rb.Close()
   
        scan, err := rb.NewScan()
        if err != nil {
                log.Fatalf("Failed to create scan: %v", err)
        }
        defer scan.Close()
   
        plan, err := scan.Plan()
        if err != nil {
                log.Fatalf("Failed to plan: %v", err)
        }
        defer plan.Close()
   
        splits := plan.Splits()
        if len(splits) == 0 {
                log.Fatal("Expected at least one split")
        }
   
        read, err := rb.NewRead()
        if err != nil {
                log.Fatalf("Failed to create table read: %v", err)
        }
        defer read.Close()
   
        reader, err := read.NewRecordBatchReader(splits)
        if err != nil {
                log.Fatalf("Failed to create record batch reader: %v", err)
        }
        defer reader.Close()
        batchIdx := 0
        type row struct {
                id   int32
                name string
        }
        var rows []row
        for {
                record, err := reader.NextRecord()
                if errors.Is(err, io.EOF) {
                        break
                }
                if err != nil {
                        log.Fatalf("Batch %d: failed to read next record: %v", 
batchIdx, err)
                }
   
                idIdx := record.Schema().FieldIndices("id")
                nameIdx := record.Schema().FieldIndices("name")
                if len(idIdx) == 0 || len(nameIdx) == 0 {
                        record.Release()
                        log.Fatalf("Batch %d: missing expected columns (id, 
name) in schema: %s", batchIdx, record.Schema())
                }
   
                idCol := record.Column(idIdx[0]).(*array.Int32)
                nameCol := record.Column(nameIdx[0]).(*array.String)
   
                for j := 0; j < int(record.NumRows()); j++ {
                        rows = append(rows, row{
                                id:   idCol.Value(j),
                                name: string([]byte(nameCol.Value(j))),
                        })
                }
                record.Release()
                batchIdx++
        }
   
        fmt.Printf("%+v\n", rows)
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to