Skip to content

[Bug]: LOAD fails on valid parquet files written by pyarrow >=22 (statistics bool misaligns footer decode) #32229

Open

Description

@iamlinjunhong

Environment

  • Commit: 80224b0 ("fix(parser): support SERIAL columns and bare table grants (fix(parser): support SERIAL columns and bare table grants #32196)"), main branch workspace
  • go.mod pins github.com/parquet-go/parquet-go v0.25.1 (go.mod line 79); upstream main still pins v0.25.1 (verified via raw go.mod)
  • OS: macOS 15, darwin/arm64; single-node standalone mo-service built with make build, frontend MySQL port 26001
  • Parquet fixtures produced by pyarrow 24.0.0 (pyarrow.parquet.write_table, all default settings)
  • No other non-default configuration

Steps to Reproduce

Two equivalent reproductions; both were executed. The Go one is fully self-contained (embeds the 941-byte file as base64), the SQL one shows the end-user entry path.

  1. End-user reproduction (SQL):
python3 - <<'PY'
import pyarrow as pa, pyarrow.parquet as pq
t = pa.table({'a': pa.array([1, 2], type=pa.int64()),
              's': pa.array(['a', 'z'*5000], type=pa.string())})
pq.write_table(t, '/tmp/min_repro.parquet', compression='snappy')   # default settings
PY
create database if exists loom_rep;
use loom_rep;
create table m(a int primary key, s varchar(6000));
load data infile {'filepath'='/tmp/min_repro.parquet', 'format'='parquet'} into table m;

The file (941 bytes) is a valid parquet file: pyarrow reads it back without any complaint (2 rows, a=[1,2], length(s)=[1,5000]).

  1. Library-level reproduction (Go): see the repro field — embedded base64 fixture + parquet.OpenFile, the same call pkg/sql/colexec/external/parquet.go:253 performs during LOAD.

Control experiments, all executed on the same build:

  • Same table written with write_statistics=False -> LOAD succeeds (2 rows, max(length(s))=5000).
  • Same table with two short values ['a','zzz'] -> LOAD succeeds (2 rows).
  • Single 200MB-string-row parquet (one_huge_200m.parquet) -> LOAD succeeds (1 row, sum(length)=200000000), so oversized values per se are fine.
  • 1000 short rows + one 10MB/huge last row (mixed-shape statistics) -> same metadata error, table left at 0 rows (clean rollback, no partial import).

Actual Behavior

LOAD DATA ... 'format'='parquet' fails with:

ERROR 20101 (HY000): internal error: convert go error to mo error reading parquet file metadata: decoding thrift payload: 4:FIELD<LIST> -> 0/1:LIST<STRUCT> -> -33:FIELD<STRUCT> -> 9:FIELD<?>: skipping unsupported thrift type 15

The whole file is rejected; the error message does not hint that column statistics of the writer are the trigger.

Expected Behavior

A valid parquet file written by the current stable pyarrow with default settings must load (2 rows). Basis: parquet LOAD is documented and exercised by the repo's own BVT suite (test/distributed/cases/load_data, e.g. parquet_dictionary.sql), parquet statistics are part of the parquet format spec, and pyarrow round-trips the file. The identical bytes load fine once the parquet-go dependency is >= v0.30.0 (verified in a standalone module: v0.30.0/v0.31.0/v0.32.0 all open it and report 2 rows).

Additional information (root cause and analysis)

  • pyarrow >= 22 writes is_min_value_exact / is_max_value_exact boolean fields into the column Statistics thrift struct (apache/arrow commit 71894728810). When a column chunk's statistics end with a single such trailing coalesced bool (short min kept, large max dropped by pyarrow's ~4096-byte truncation), parquet-go v0.25.1's thrift decoder consumes one byte too many for the bool field, misaligning the rest of the footer decode and producing garbage field ids (e.g. -33) and the bogus thrift type 15 error.
  • Upstream fixed exactly this: parquet-go/parquet-go issue (aoe): always set the meta dir same as db dir #511 "Column statistics reader may misalign reader" / PR (aoe): set dir for meta conf #512 "Do not skip byte for bool field with coalesce enabled" (commit dd463c7aa3bf, released in v0.30.0).
  • I bisected the fix version in a standalone Go module against the same fixture: v0.25.1, v0.26.1, v0.26.2, v0.26.4, v0.27.0, v0.28.0, v0.29.0 all fail; v0.30.0+ opens it correctly.
  • MO impact path: pkg/sql/colexec/external/parquet.go:253 parquet.OpenFile(...) fails -> whole LOAD aborted.
  • Recommendation: upgrade github.com/parquet-go/parquet-go from v0.25.1 to >= v0.30.0 (latest v0.32.0). This only fixes third-party file decoding; no MO data format changes, backward compatible with existing data and behavior.
  • Workaround until the bump: rewrite source files with write_statistics=False, or generate them with pyarrow < 22.
  • Note on related issue [Bug]: load parquet file report 'internal error: convert go error to mo error reading parquet file metadata'. #23598: it reports the identical error string but was closed as unreproducible — the original fixture was lost ("原始数据丢失") and verification was done against a different regenerated file. Nothing was fixed for it; the deterministic minimal repro above likely explains it, but since [Bug]: load parquet file report 'internal error: convert go error to mo error reading parquet file metadata'. #23598 is closed/unfixed and unverified, this report is filed as the actionable one.
  • Out of scope / not affected: MO parquet OUTFILE export/round-trips (MO's own writer is unaffected by the reader bug); CSV/JSONLINE loads.
Full reproduction, exactly as Loom ran it
// Copyright 2026 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//	http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package external

import (
	"bytes"
	"encoding/base64"
	"testing"

	"github.com/parquet-go/parquet-go"
)

// loomB64ParquetCoalescedBool is a 941-byte parquet file written by pyarrow
// 24.0.0 with default settings:
//
//	table {'a': [1, 2] (int64), 's': ['a', 'z'*5000] (string)}
//
// Column s statistics keep exactly one trailing coalesced bool
// (is_min_value_exact=true; the 5000-byte max is dropped by pyarrow's 4096
// truncation limit), which is the misalignment trigger for parquet-go
// v0.25.1's thrift footer decoder (upstream parquet-go/parquet-go#511,
// fixed by PR #512 released in v0.30.0).
const loomB64ParquetCoalescedBool = "UEFSMRUEFSAVJEwVBBUAEgAAEDwBAAAAAAAAAAIAAAAAAAAAFQAVEhUWLBUEFRAVBhUGHBgIAgAAAAAAAAAYCAEAAAAAAAAAFgAoCAIAAAAAAAAAGAgBAAAAAAAAABERAAAACSACAAAABAEBAwIVBBWiThXyA0wVBBUAEgAAkSckAQAAAGGIEwAAev4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4BAP4B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
// column's statistics contain a single trailing coalesced bool: the thrift
// decoder consumes one byte too many and misaligns the whole footer.
// This is exactly how LOAD fails on such files (pkg/sql/colexec/external/
// parquet.go calls parquet.OpenFile). Expected behavior: file opens with 2
// rows, as it does with parquet-go >= v0.30.0.
func TestLoomParquetCoalescedBoolStatRepro(t *testing.T) {
	data, err := base64.StdEncoding.DecodeString(loomB64ParquetCoalescedBool)
	if err != nil {
		t.Fatal(err)
	}
	if !bytes.Equal(data[:4], []byte("PAR1")) || !bytes.Equal(data[len(data)-4:], []byte("PAR1")) {
		t.Fatal("fixture is not a parquet file")
	}
	f, err := parquet.OpenFile(bytes.NewReader(data), int64(len(data)))
	if err == nil {
		_ = f
		return
	}
	t.Fatalf("parquet-go failed to open a valid pyarrow parquet file: %v\n"+
		"expected behavior: file opens with 2 rows (works with parquet-go >= v0.30.0)", err)
}

// loomB64ParquetCoalescedBoolNostats is the same table written with
// write_statistics=False: no statistics struct, so no misalignment. It
// must always open, proving the rejection is caused purely by the
// statistics thrift structure.
const loomB64ParquetCoalescedBoolNostats = "UEFSMRUEFSAVJEwVBBUAEgAAEDwBAAAAAAAAAAIAAAAAAAAAFQAVEhUWLBUEFRAVBhUGHAAAAAkgAgAAAAQBAQMCFQQVok4V8gNMFQQVABIAAJEnJAEAAABhiBMAAHr+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQD+AQANARUAFRIVFiwVBBUQFQYVBhwAAAAJIAIAAAAEAQEDAhUEGTw1ABgGc2NoZW1hFQQAFQQlAhgBYQAVDCUCGAFzJQBMHAAAABYEGRwZLCYAHBUEGTUABhAZGAFhFQIWBBZ0FnwmSCYIKSwVBBUAFQIAFQAVEBUCADwpBhkmAAQAAAAmABwVDBk1AAYQGRgBcxUCFgQW+k4WzgQmlgUmhAEpLBUEFQAVAgAVABUQFQIAPBaSThkGGSYABAAAABbuTxYEJggWygUAGRwYDEFSUk9XOnNjaGVtYRjsAS8vLy8vNmdBQUFBUUFBQUFBQUFLQUF3QUJnQUZBQWdBQ2dBQUFBQUJCQUFNQUFBQUNBQUlBQUFBQkFBSUFBQUFCQUFBQUFJQUFBQkFBQUFBQkFBQUFOai8vLzhBQUFFRkVBQUFBQmdBQUFBRUFBQUFBQUFBQUFFQUFBQnpBQUFBQkFBRUFBUUFBQUFRQUJRQUNBQUdBQWNBREFBQUFCQUFFQUFBQUFBQUFRSVFBQUFBSEFBQUFBUUFBQUFBQUFBQUFRQUFBR0VBQUFBSUFBd0FDQUFIQUFnQUFBQUFBQUFCUUFBQUFBQUFBQUE9ABggcGFycXVldC1jcHAtYXJyb3cgdmVyc2lvbiAyNC4wLjAZLBwAABwAAADSAQAAUEFSMQ=="

func TestLoomParquetCoalescedBoolStatReproNostatsControl(t *testing.T) {
	data, err := base64.StdEncoding.DecodeString(loomB64ParquetCoalescedBoolNostats)
	if err != nil {
		t.Fatal(err)
	}
	if !bytes.Equal(data[:4], []byte("PAR1")) || !bytes.Equal(data[len(data)-4:], []byte("PAR1")) {
		t.Fatal("control fixture is not a parquet file")
	}
	f, err := parquet.OpenFile(bytes.NewReader(data), int64(len(data)))
	if err != nil {
		t.Fatalf("control file (stats disabled at write time) must not fail: %v", err)
	}
	_ = f
}


RUN COMMAND (executed from the module root of a mo-service build workspace):
  export CGO_CFLAGS="-I$PWD/cgo -I$PWD/thirdparties/install/include"
  export CGO_LDFLAGS="-L$PWD/thirdparties/install/lib -L$PWD/cgo"
  go test ./pkg/sql/colexec/external/ -run 'TestLoomParquetCoalescedBoolStat' -count=1 -v

Save the file above as pkg/sql/colexec/external/loom_test_parquet_coalesced_bool_test.go
(any package file name works). TestLoomParquetCoalescedBoolStatRepro FAILS on the pinned
github.com/parquet-go/parquet-go v0.25.1 (this is the bug); it passes once the dependency
is upgraded to >= v0.30.0. TestLoomParquetCoalescedBoolStatReproNostatsControl must always
pass. A full e2e variant (SQL against a running mo-service) is in the body.

Found by Loom bug hunt (module: custom-de41a00730; tests: unit, white-box, end-to-end, concurrency; severity: S0)

Activity

  1. self-assigned this
    on Nov 5, 2026
  2. added
    kind/bug
    severity/s0
    on Nov 5, 2026
  3. iamlinjunhong commented on Nov 10, 2026

    @iamlinjunhong
    ContributorAuthor

    Update on #32306: following @fengttt's review, I plan to close that PR because copying parquet-go into MatrixOne's third_party directory is not the right dependency-maintenance approach; this issue remains unresolved.

    The follow-up should keep the required compatibility fix in a separate parquet-go fork and reference a pinned version through go.mod, retaining the MatrixOne regression coverage and preserving existing writer statistics behavior. As documented in this issue, upstream already fixed the original decoding bug in PR parquet-go/parquet-go#512 (released in v0.30.0); we should reuse that fix, propose any additional necessary changes upstream, and keep the fork synchronized until we can use a compatible upstream release directly.

    The reproducer, fixtures, and validation recorded in #32306 remain useful evidence for the follow-up.

  4. added
    severity/s1
    and removed
    severity/s0
    on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s1

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions