shachibista opened a new issue, #1366:
URL: https://github.com/apache/arrow-go/issues/1366

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   I am trying to write a parquet file with statistics which contains a nested 
field, however it seems like the generated statistics are incorrect. As a 
result, duckdb cannot read the file.
   
   ```
   memory D select * from read_parquet('stats.parquet');
   Conversion Error:
   Could not convert Timestamp(MS) to Timestamp(US)
   memory D select * from read_parquet('nostats.parquet');
   ┌─────────────┐
   │   events    │
   │ timestamp[] │
   ├─────────────┤
   │ NULL        │
   └─────────────┘
   ```
   
   Minimal script for reproduction:
   
   ```golang
   package main
   
   import (
        "log"
        "os"
   
        "github.com/apache/arrow-go/v18/arrow"
        "github.com/apache/arrow-go/v18/arrow/array"
        "github.com/apache/arrow-go/v18/arrow/memory"
        "github.com/apache/arrow-go/v18/parquet"
        "github.com/apache/arrow-go/v18/parquet/pqarrow"
   )
   
   func main() {
        bug("stats.parquet", true)
        bug("nostats.parquet", false)
   }
   
   func bug(outfile string, stats bool) {
        timestampType := &arrow.TimestampType{Unit: arrow.Millisecond}
        schema := arrow.NewSchema([]arrow.Field{{
                Name:     "events",
                Type:     arrow.ListOf(timestampType),
                Nullable: true,
        }}, nil)
   
        builder := array.NewRecordBuilder(memory.DefaultAllocator, schema)
        events := builder.Field(0).(*array.ListBuilder)
        events.AppendNull() // One row whose list is NULL; no timestamp value 
exists.
        record := builder.NewRecordBatch()
        builder.Release()
        defer record.Release()
   
        out, err := os.Create(outfile)
        check(err)
   
        writer, err := pqarrow.NewFileWriter(
                schema,
                out,
                parquet.NewWriterProperties(
                        parquet.WithVersion(parquet.V2_LATEST),
                        parquet.WithDataPageVersion(parquet.DataPageV2),
                        parquet.WithStats(stats),
                ),
                pqarrow.DefaultWriterProps(),
        )
        check(err)
        check(writer.WriteBuffered(record))
        check(writer.Close())
   }
   
   func check(err error) {
        if err != nil {
                log.Fatal(err)
        }
   }
   ```
   
   When inspecting `stats.parquet` with `parquet-tools`:
   
   ```
   $ parquet-tools inspect --detail stats.parquet
   [... snip ...]
   ■■■■■■■■■■■■■■■■■■■■■■■■path_in_schema = list
   ■■■■■■■■■■■■■■■■■■■■■■■■■■■■events
   ■■■■■■■■■■■■■■■■■■■■■■■■■■■■list
   ■■■■■■■■■■■■■■■■■■■■■■■■■■■■element
   ■■■■■■■■■■■■■■■■■■■■■■■■num_values = 1
   ■■■■■■■■■■■■■■■■■■■■■■■■total_uncompressed_size = 70
   ■■■■■■■■■■■■■■■■■■■■■■■■total_compressed_size = 70
   ■■■■■■■■■■■■■■■■■■■■■■■■data_page_offset = 4
   ■■■■■■■■■■■■■■■■■■■■■■■■statistics = Statistics
   ■■■■■■■■■■■■■■■■■■■■■■■■■■■■max = b'\x00\x00\x00\x00\x00\x00\x00\x80'
   ■■■■■■■■■■■■■■■■■■■■■■■■■■■■min = b'\xff\xff\xff\xff\xff\xff\xff\x7f'
   ■■■■■■■■■■■■■■■■■■■■■■■■■■■■null_count = 1
   ■■■■■■■■■■■■■■■■■■■■■■■■■■■■max_value = b'\x00\x00\x00\x00\x00\x00\x00\x80'
   ■■■■■■■■■■■■■■■■■■■■■■■■■■■■min_value = b'\xff\xff\xff\xff\xff\xff\xff\x7f'
   [... snip ...]
   ```
   
   `min` and `max` correspond to `-9223372036854775808` (`MinInt64`) and 
`9223372036854775807` (`MinInt64`).
   
   ### Component(s)
   
   Parquet


-- 
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