github.com/vc42/parquet-go@v0.0.0-20240320194221-1a9adb5f23f5/errors.go (about)

     1  package parquet
     2  
     3  import (
     4  	"errors"
     5  )
     6  
     7  var (
     8  	// ErrCorrupted is an error returned by the Err method of ColumnPages
     9  	// instances when they encountered a mismatch between the CRC checksum
    10  	// recorded in a page header and the one computed while reading the page
    11  	// data.
    12  	ErrCorrupted = errors.New("corrupted parquet page")
    13  
    14  	// ErrMissingRootColumn is an error returned when opening an invalid parquet
    15  	// file which does not have a root column.
    16  	ErrMissingRootColumn = errors.New("parquet file is missing a root column")
    17  
    18  	// ErrRowGroupSchemaMissing is an error returned when attempting to write a
    19  	// row group but the source has no schema.
    20  	ErrRowGroupSchemaMissing = errors.New("cannot write rows to a row group which has no schema")
    21  
    22  	// ErrRowGroupSchemaMismatch is an error returned when attempting to write a
    23  	// row group but the source and destination schemas differ.
    24  	ErrRowGroupSchemaMismatch = errors.New("cannot write row groups with mismatching schemas")
    25  
    26  	// ErrRowGroupSortingColumnsMismatch is an error returned when attempting to
    27  	// write a row group but the sorting columns differ in the source and
    28  	// destination.
    29  	ErrRowGroupSortingColumnsMismatch = errors.New("cannot write row groups with mismatching sorting columns")
    30  
    31  	// ErrSeekOutOfRange is an error returned when seeking to a row index which
    32  	// is less than the first row of a page.
    33  	ErrSeekOutOfRange = errors.New("seek to row index out of page range")
    34  
    35  	// ErrUnexpectedDictionaryPage is an error returned when a page reader
    36  	// encounters a dictionary page after the first page, or in a column
    37  	// which does not use a dictionary encoding.
    38  	ErrUnexpectedDictionaryPage = errors.New("unexpected dictionary page")
    39  
    40  	// ErrMissingPageHeader is an error returned when a page reader encounters
    41  	// a malformed page header which is missing page-type-specific information.
    42  	ErrMissingPageHeader = errors.New("missing page header")
    43  
    44  	// ErrUnexpectedRepetitionLevels is an error returned when attempting to
    45  	// decode repetition levels into a page which is not part of a repeated
    46  	// column.
    47  	ErrUnexpectedRepetitionLevels = errors.New("unexpected repetition levels")
    48  
    49  	// ErrUnexpectedDefinitionLevels is an error returned when attempting to
    50  	// decode definition levels into a page which is part of a required column.
    51  	ErrUnexpectedDefinitionLevels = errors.New("unexpected definition levels")
    52  )
    53  
    54  type errno int
    55  
    56  const (
    57  	ok errno = iota
    58  	indexOutOfBounds
    59  )
    60  
    61  func (e errno) check() {
    62  	switch e {
    63  	case ok:
    64  	case indexOutOfBounds:
    65  		panic("index out of bounds")
    66  	default:
    67  		panic("BUG: unknown error code")
    68  	}
    69  }