Involved Source Files Package parquet provides an implementation of Apache Parquet for Go.
Apache Parquet is an open-source columnar data storage format using the record
shredding and assembly algorithm to accommodate complex data structures which
can then be used to efficiently store the data.
This implementation is a native go implementation for reading and writing the
parquet file format.
# Install
You can download the library and cli utilities via:
go get -u github.com/apache/arrow-go/v18/parquet
go install github.com/apache/arrow-go/v18/parquet/cmd/parquet_reader@latest
go install github.com/apache/arrow-go/v18/parquet/cmd/parquet_schema@latest
# Modules
This top level parquet package contains the basic common types and reader/writer
properties along with some utilities that are used throughout the other modules.
The file module contains the functions for directly reading/writing parquet files
including Column Readers and Column Writers.
The metadata module contains the types for managing the lower level file/rowgroup/column
metadata inside of a ParquetFile including inspecting the statistics.
The pqarrow module contains helper functions and types for converting directly
between Parquet and Apache Arrow formats.
The schema module contains the types for manipulating / inspecting / creating
parquet file schemas.
# Primitive Types
The Parquet Primitive Types and their corresponding Go types are Boolean (bool),
Int32 (int32), Int64 (int64), Int96 (parquet.Int96), Float (float32), Double (float64),
ByteArray (parquet.ByteArray) and FixedLenByteArray (parquet.FixedLenByteArray).
# Encodings
The encoding types supported in this package are:
- Plain
- Plain/RLE Dictionary
- Delta Binary Packed (only integer types)
- Delta Byte Array (only ByteArray)
- Delta Length Byte Array (only ByteArray)
- Byte Stream Split (Float, Double, Int32, Int64, FixedLenByteArray)
- ALP, Adaptive Lossless floating-Point (Float, Double). The Parquet
format marks ALP as a preview encoding, so writing it is opt-in: enable
it with WithALPEncoding, select it per column with WithEncodingFor or
WithEncodingPath, and turn off dictionary encoding for those columns.
Reading needs no option.
Tip: Some platforms don't necessarily support all kinds of encodings. If you're not
sure what to use, just use Plain and Dictionary encoding.
# Arrow to Parquet Type Mappings
When reading and writing Parquet, the parquet package converts between Arrow
and Parquet types in the manner described in the table below.
When converting a Parquet type where a large and non-large offset Arrow type
would work, the non-large variant is chosen. If the Parquet file is written
with `WithStoreSchema`, types will be preserved and dictionaries will be
restored when round-tripping.
Arrow Type Parquet Physical Type Parquet Logical Type
---------- --------------------- --------------------
NULL Int32 Null
BOOL Boolean -
INT8 Int32 Int(8, signed)
UINT8 Int32 Int(8, unsigned)
INT16 Int32 Int(16, signed)
UINT16 Int32 Int(16, unsigned)
INT32 Int32 Int(32, signed)
UINT32 Int32 Int(32, unsigned)
INT64 Int64 Int(64, signed)
UINT64 Int64 Int(64, unsigned)
FLOAT16 FixedLenByteArray(2) Float16
FLOAT32 Float -
FLOAT64 Double -
STRING ByteArray String
LARGE_STRING ByteArray String
BINARY ByteArray -
LARGE_BINARY ByteArray -
FIXED_SIZE_BINARY FixedLenByteArray -
DECIMAL128 Int32/Int64/FLBA* Decimal
DECIMAL256 Int32/Int64/FLBA* Decimal
DATE32 Int32 Date
DATE64 Int32 Date
TIMESTAMP Int64 or Int96 Timestamp
TIME32 Int32 Time(millis)
TIME64 Int64 Time(micros/nanos)
LIST Group (LIST) -
FIXED_SIZE_LIST Group (LIST) -
STRUCT Group -
MAP Group (MAP) -
DICTIONARY (converted to value type) -
EXTENSION (depends on storage) (may be custom)
* FLBA means FixedLenByteArray
Unsupported Arrow Types (will return arrow.ErrNotImplemented):
DURATION, INTERVAL_MONTHS, INTERVAL_DAY_TIME, INTERVAL_MONTH_DAY_NANO
SPARSE_UNION, DENSE_UNION
STRING_VIEW, BINARY_VIEW, LIST_VIEW, LARGE_LIST_VIEW
LARGE_LIST, RUN_END_ENCODED
DECIMAL32, DECIMAL64encryption_properties.goreader_properties.gotypes.goversion_string.gowriter_properties.go
Code Examples
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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 main
import (
"bytes"
"context"
"fmt"
"log"
"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/compress"
"github.com/apache/arrow-go/v18/parquet/file"
"github.com/apache/arrow-go/v18/parquet/pqarrow"
)
// In a real project, this should be tuned based on memory usage and performance needs
const batchSize = 2
// List of fields to read
var colNames = []string{"intField", "stringField", "listField"}
func main() {
// --- Phase 1: Writing parquet file ---
// Create an in-memory buffer to simulate a file
// For writing real file to disk, use os.Create instead
buffer := &bytes.Buffer{}
// Create a schema with three fields
fields := []arrow.Field{
{Name: "intField", Type: arrow.PrimitiveTypes.Int32, Nullable: false},
{Name: "stringField", Type: arrow.BinaryTypes.String, Nullable: false},
{Name: "listField", Type: arrow.ListOf(arrow.PrimitiveTypes.Float32), Nullable: false},
}
schema := arrow.NewSchema(fields, nil)
// Create parquet writer props with snappy compression
writerProps := parquet.NewWriterProperties(
parquet.WithCompression(compress.Codecs.Snappy),
)
// WithStoreSchema embeds the original Arrow schema into the Parquet file metadata,
// allowing it to be accurately restored when reading. This ensures correct handling
// of advanced types like dictionaries and improves cross-language type consistency
// in libraries that support the "ARROW:schema" metadata.
arrowWriterProps := pqarrow.NewArrowWriterProperties(
pqarrow.WithStoreSchema(),
)
// Create a parquet writer
writer, err := pqarrow.NewFileWriter(schema, buffer, writerProps, arrowWriterProps)
if err != nil {
log.Fatalf("Failed create parquet writer: %v", err)
}
// Create a record builder
recordBuilder := array.NewRecordBuilder(memory.DefaultAllocator, schema)
// Create a builder for each field
intFieldBuilder := recordBuilder.Field(0).(*array.Int32Builder)
stringFieldBuilder := recordBuilder.Field(1).(*array.StringBuilder)
listFieldBuilder := recordBuilder.Field(2).(*array.ListBuilder)
// Get the builder for the list's values (Float32)
fl32Builder := listFieldBuilder.ValueBuilder().(*array.Float32Builder)
// Append values for each field
intFieldBuilder.AppendValues([]int32{38, 13, 53, 93, 66}, nil)
stringFieldBuilder.AppendValues([]string{"val1", "val2", "val3", "val4", "val5"}, nil)
// Append five lists, each containing the same float32 values
for i := 0; i < 5; i++ {
listFieldBuilder.Append(true)
fl32Builder.AppendValues([]float32{1.0, 2.0, 4.0, 8.0}, nil)
}
// Create a record
record := recordBuilder.NewRecordBatch()
if err := writer.Write(record); err != nil {
log.Fatalf("Failed to write record: %v", err)
}
record.Release()
recordBuilder.Release()
// IMPORTANT: Close the writer to finalize the file
if err := writer.Close(); err != nil {
log.Fatalf("Failed to close parquet writer: %v", err)
}
// --- Phase 2: Reading parquet file ---
// Create a Parquet reader from the in-memory buffer
// For reading real file from disk, use file.OpenParquetFile() instead
fileReader, err := file.NewParquetReader(bytes.NewReader(buffer.Bytes()))
if err != nil {
log.Fatalf("Failed to create parquet reader: %v", err)
}
defer func() {
if err := fileReader.Close(); err != nil {
log.Printf("Failed to close file reader: %v", err)
}
}()
// Create arrow read props, specifying the batch size
arrowReadProps := pqarrow.ArrowReadProperties{BatchSize: batchSize}
// Create an arrow reader for the parquet file
arrowReader, err := pqarrow.NewFileReader(fileReader, arrowReadProps, memory.DefaultAllocator)
if err != nil {
log.Fatalf("Failed to create arrow reader: %v", err)
}
// Get the arrow schema from the file reader
schema, err = arrowReader.Schema()
if err != nil {
log.Fatalf("Failed to get schema: %v", err)
}
// colIndices can be nil to read all columns. Here, we specify which columns to read
colIndices := make([]int, len(colNames))
for idx := range colNames {
colIndices[idx] = schema.FieldIndices(colNames[idx])[0]
}
// Get a record reader from the file to iterate over
recordReader, err := arrowReader.GetRecordReader(context.TODO(), colIndices, nil)
if err != nil {
log.Fatalf("Failed to get record reader: %v", err)
}
defer recordReader.Release()
for recordReader.Next() {
// Create a record
record := recordReader.RecordBatch()
// Get columns
intCol := record.Column(0).(*array.Int32)
stringCol := record.Column(1).(*array.String)
listCol := record.Column(2).(*array.List)
listValueCol := listCol.ListValues().(*array.Float32)
// Iterate over the rows within the current record
for idx := range int(record.NumRows()) {
// For the list column, get the start and end offsets for the current row
start, end := listCol.ValueOffsets(idx)
fmt.Printf("%d %s %v\n", intCol.Value(idx), stringCol.Value(idx), listValueCol.Float32Values()[start:end])
}
}
}
Package-Level Type Names (total 32)
/* sort by: | */
AADPrefixVerifier is an interface for any object that can be used to verify the identity of the file being decrypted.
It should panic if the provided AAD identity is bad.
In a data set, AAD Prefixes should be collected, and then checked for missing files. Verify identity of file. panic if bad
func WithPrefixVerifier(verifier AADPrefixVerifier) FileDecryptionOption
Algorithm describes how something was encrypted, representing the EncryptionAlgorithm object from the
parquet.thrift file.Aadstruct{AadPrefix []byte; AadFileUnique []byte; SupplyAadPrefix bool}AlgoCipher ToThrift returns an instance to be used for serializing when writing a file.
func AlgorithmFromThrift(enc *format.EncryptionAlgorithm) (ret Algorithm)
func (*FileEncryptionProperties).Algorithm() Algorithm
ByteArray is a type to be utilized for representing the Parquet ByteArray physical type, represented as a byte slice( ByteArray) Bytes() []byte Len returns the current length of the ByteArray, equivalent to len(bytearray) String returns a string representation of the ByteArray
ByteArray : github.com/apache/arrow-go/v18/internal/hashing.ByteSlice
ByteArray : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer
ByteArray : github.com/pandatix/go-abnf.ElemItf
ByteArray : expvar.Var
ByteArray : fmt.Stringer
ColumnDecryptionProperties are the specifications for how to decrypt a given column. Clone returns a new instance of ColumnDecryptionProperties with the same key and column ColumnPath returns which column these properties describe how to decrypt IsUtilized returns whether or not these properties have been used for decryption already Key returns the key specified to decrypt this column, or is empty if the Footer Key should be used. SetUtilized is used by the reader to specify when we've decrypted the column and have used the key so we know
to wipe out the keys. WipeOutDecryptionKey is called after decryption to ensure the key doesn't stick around and get re-used.
func NewColumnDecryptionProperties(column string, opts ...ColumnDecryptOption) *ColumnDecryptionProperties
func (*ColumnDecryptionProperties).Clone() *ColumnDecryptionProperties
ColumnEncryptionProperties specifies how to encrypt a given column Clone returns a instance of ColumnEncryptionProperties with the same key and metadata ColumnPath returns which column these properties are for IsEncrypted returns true if this column is encrypted. IsEncryptedWithFooterKey returns if this column was encrypted with the footer key itself, or false if a separate
key was used for encrypting this column. IsUtilized returns whether or not these properties have already been used, if the key is empty
then this is always false Key returns the key used for encrypting this column if it isn't encrypted by the footer key KeyMetadata returns the key identifier which is used with a KeyRetriever to get the key for this column if it is not
encrypted using the footer key SetUtilized is used for marking it as utilized once it is used in FileEncryptionProperties
as the encryption key will be wiped out on completion of writing WipeOutEncryptionKey Clears the encryption key, used after completion of file writing
func NewColumnEncryptionProperties(name string, opts ...ColumnEncryptOption) *ColumnEncryptionProperties
func (*ColumnEncryptionProperties).Clone() *ColumnEncryptionProperties
func (*FileEncryptionProperties).ColumnEncryptionProperties(path string) *ColumnEncryptionProperties
func (*WriterProperties).ColumnEncryptionProperties(path string) *ColumnEncryptionProperties
ColumnOrder is the Column Order from the parquet.thrift
func github.com/apache/arrow-go/v18/parquet/schema.(*Column).ColumnOrder() ColumnOrder
func github.com/apache/arrow-go/v18/parquet/schema.(*Schema).UpdateColumnOrders(orders []ColumnOrder) error
var DefaultColumnOrder
DecryptionKeyRetriever is an interface for getting the desired key for decryption from metadata. It should take in
some metadata identifier and return the actual Key to use for decryption.( DecryptionKeyRetriever) GetKey(keyMetadata []byte) string
func WithKeyRetriever(retriever DecryptionKeyRetriever) FileDecryptionOption
FileDecryptionProperties define the File Level configuration for decrypting a parquet file. Once constructed they are
read only.KeyRetrieverDecryptionKeyRetrieverVerifierAADPrefixVerifier AadPrefix returns the prefix to be supplied for constructing the identification strings when decrypting Clone returns a new instance of these properties, changing the prefix if set (keeping the same prefix if left empty) ColumnKey returns the key to be used for decrypting the provided column. FooterKey returns the key utilized for decrypting the Footer if encrypted and any columns that are encrypted with
the footer key. IsUtilized returns whether or not this instance has been used to decrypt a file. If the footer key and prefix are
empty and there are no column decryption properties, then this is always false. PlaintextFilesAllowed returns whether or not this instance of decryption properties are allowed on a plaintext file. PlaintextFooterIntegrity returns whether or not an integrity check will be performed on a plaintext footer for an
encrypted file. SetUtilized is called to mark this instance as utilized once it is used to read a file. A single instance
can be used for reading one file only. Setting this ensures the keys will be wiped out upon completion of file reading. WipeOutDecryptionKeys will clear all the keys for this instance including the column level ones, this will be called
after this instance has been utilized.
func NewFileDecryptionProperties(opts ...FileDecryptionOption) *FileDecryptionProperties
func (*FileDecryptionProperties).Clone(newAadPrefix string) *FileDecryptionProperties
FileEncryptionProperties describe how to encrypt a parquet file when writing data. Algorithm returns the description of how we will perform the encryption, the algorithm, prefixes, and so on. Clone allows returning an identical property setup for another file with the option to update the aadPrefix,
(if given the empty string, the current aad prefix will be used) since a single instance can only be used
to encrypt one file before wiping out the keys. ColumnEncryptionProperties returns the properties for encrypting a given column.
This may be nil for columns that aren't encrypted or may be default properties. EncryptedColumns returns the mapping of column paths to column encryption properties EncryptedFooter returns if the footer for this file should be encrypted or left in plaintext. FileAad returns the aad identification to be used at the file level which gets concatenated with the row and column
information for encrypting data. FooterKey returns the actual key used to encrypt the footer if it is encrypted, or to encrypt any columns which
will be encrypted with it rather than their own keys. FooterKeyMetadata is used for retrieving a key from the key retriever in order to set the footer key IsUtilized returns whether or not this instance has been used to encrypt a file SetUtilized is called after writing a file. A FileEncryptionProperties object can be used for writing one file only,
the encryption keys will be wiped out upon completion of writing the file. WipeOutEncryptionKeys clears all of the encryption keys for this and the columns
func NewFileEncryptionProperties(footerKey string, opts ...EncryptOption) *FileEncryptionProperties
func (*FileEncryptionProperties).Clone(newAadPrefix string) *FileEncryptionProperties
func (*WriterProperties).FileEncryptionProperties() *FileEncryptionProperties
func WithEncryptionProperties(props *FileEncryptionProperties) WriterProperty
FixedLenByteArray is a go type to represent a FixedLengthByteArray as a byte slice( FixedLenByteArray) Bytes() []byte Len returns the current length of this FixedLengthByteArray, equivalent to len(fixedlenbytearray) String returns a string representation of the FixedLenByteArray
FixedLenByteArray : github.com/apache/arrow-go/v18/internal/hashing.ByteSlice
FixedLenByteArray : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer
FixedLenByteArray : github.com/pandatix/go-abnf.ElemItf
FixedLenByteArray : expvar.Var
FixedLenByteArray : fmt.Stringer
Int96 is a 12 byte integer value utilized for representing timestamps as a 64 bit integer and a 32 bit
integer. SetNanoSeconds sets the Nanosecond field of the Int96 timestamp to the provided value String provides the string representation as a timestamp via converting to a time.Time
and then calling String ToTime returns a go time.Time object that represents the same time instant as the given Int96 value ToTimestamp converts an Int96 value to an Arrow nanosecond timestamp.
Int96 : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer
Int96 : github.com/pandatix/go-abnf.ElemItf
Int96 : expvar.Var
Int96 : fmt.Stringer
func NewInt96(v [3]uint32) (out Int96)
ReaderAtSeeker is a combination of the ReaderAt and ReadSeeker interfaces
from the io package defining the only functionality that is required
in order for a parquet file to be read by the file functions. We just need
to be able to call ReadAt, Read, and Seek( ReaderAtSeeker) ReadAt(p []byte, off int64) (n int, err error)( ReaderAtSeeker) Seek(offset int64, whence int) (int64, error)
github.com/apache/arrow-go/v18/arrow/ipc.ReadAtSeeker(interface)
github.com/apache/arrow-go/v18/internal/utils.Reader(interface)
github.com/coreos/etcd/pkg/fileutil.LockedFile
github.com/go-text/typesetting/font/opentype.Resource(interface)
*github.com/klauspost/compress/s2.ReadSeeker
*github.com/polarsignals/wal/fs.File
*bytes.Reader
*io.SectionReader
mime/multipart.File(interface)
*os.File
*strings.Reader
ReaderAtSeeker : io.ReaderAt
ReaderAtSeeker : io.Seeker
ReaderProperties are used to define how the file reader will handle buffering and allocating buffers Default buffer size to utilize when reading chunks, when reading page
headers or other metadata, this buffer may be increased if necessary
to read in the necessary metadata. The value here is simply the default
initial BufferSize when reading a new chunk. If this is set to true, then the reader will use SectionReader to
just use the read stream when reading data. Otherwise we will buffer
the data we're going to read into memory first and then read that buffer.
When accessing data from IO sources with higher latency, like S3, setting this
to false may improve performance by reading the entire row group at once rather
than sending multiple smaller IO requests. For IO streams with low latency, setting
this to true can optimize memory usage for the reader. Additionally, this can decrease
the amount of data retrieved when only needs to access small portions of the parquet file. create with NewFileDecryptionProperties if dealing with an encrypted file MaxCompressedPageSize limits the compressed body size declared by a page
header. Values less than or equal to zero use DefaultMaxCompressedPageSize. MaxUncompressedPageSize limits the uncompressed body size declared by a
page header. Values less than or equal to zero use DefaultMaxUncompressedPageSize. PageStreamingEnabled, when true, decodes eligible data pages incrementally instead
of decoding the whole uncompressed page at once. A decode aliases the batch's
values directly in a reusable stream buffer (min(1 MiB, page size)) rather than
materializing the page, so the read batch is clipped toward the average value
width to keep one decode's values near the buffer size. Peak memory is then
best-effort roughly that buffer plus the largest single value, the caller's batch
and the level buffers; skewed value sizes may overshoot the target. Eligible pages
are PLAIN-encoded V1/V2 data pages larger than 1 MiB (smaller pages fit in a single
buffer, so streaming only adds overhead), of a streaming-capable, unencrypted codec
(UNCOMPRESSED/GZIP/BROTLI/ZSTD) for a supported physical type; every other page is
read whole as before. Default false (no behavior change to decoded values).
Note: a streaming page's raw Page.Data() (via GetColumnPageReader) returns just its
level region; the decoded values read through RowGroup.Column()/ReadBatch are the
same as without streaming. Allocator returns the allocator that the properties were initialized with GetMaxCompressedPageSize returns the configured compressed page limit. GetMaxUncompressedPageSize returns the configured uncompressed page limit. GetStream returns a section of the underlying reader based on whether or not BufferedStream is enabled.
If BufferedStreamEnabled is true, it creates an io.SectionReader, otherwise it will read the entire section
into a buffer in memory and return a bytes.NewReader for that buffer.
func NewReaderProperties(alloc memory.Allocator) *ReaderProperties
WriterProperties is the collection of properties to use for writing a parquet file. The values are
read only once it has been constructed. ALPEncodingEnabled reports whether columns may use the ALP encoding by
default. Use ALPEncodingEnabledFor for a specific column. ALPEncodingEnabledFor reports whether the given column may be written with the
ALP encoding, or the default value if the column was not separately specified. ALPEncodingEnabledPath is the same as ALPEncodingEnabledFor but takes a
ColumnPath object. ALPVectorSize returns the default number of values in each ALP vector. Use
ALPVectorSizeFor for a specific column. ALPVectorSizeFor returns how many values each ALP vector of the given column
holds, or the default if the column was not separately specified. ALPVectorSizePath is the same as ALPVectorSizeFor but takes a ColumnPath
object. AdaptiveBloomFilterEnabled returns the default value for whether or not adaptive bloom filters are enabled AdaptiveBloomFilterEnabledFor returns whether or not adaptive bloom filters are enabled for the given column path AdaptiveBloomFilterEnabledPath is the same as AdaptiveBloomFilterEnabledFor but takes a ColumnPath(*WriterProperties) Allocator() memory.Allocator BloomFilterCandidates returns the default number of candidates to use for bloom filters BloomFilterCandidatesFor returns the number of candidates to use for the given column path BloomFilterCandidatesPath is the same as BloomFilterCandidatesFor but takes a ColumnPath BloomFilterEnabled returns the default value for whether or not bloom filters are enabled BloomFilterEnabledFor returns whether or not bloom filters are enabled for the given column path BloomFilterEnabledPath is the same as BloomFilterEnabledFor but takes a ColumnPath BloomFilterFPP returns the default false positive probability for bloom filters BloomFilterFPPFor returns the false positive probability for the given column path BloomFilterFPPPath is the same as BloomFilterFPPFor but takes a ColumnPath BloomFilterNDV returns the default number of distinct values to use for bloom filters BloomFilterNDVFor returns the number of distinct values to use for the given column path BloomFilterNDVPath is the same as BloomFilterNDVFor but takes a ColumnPath ColumnEncryptionProperties returns the specific properties for encryption that will be used for the given column path Compression returns the default compression type that will be used for any columns that don't
have a specific compression defined. CompressionFor will return the compression type that is specified for the given column path, or
the default compression codec if there isn't one specific to this column. CompressionLevel returns the default compression level that will be used for any column
that doesn't have a compression level specified for it. CompressionLevelFor returns the compression level that will be utilized for the given column,
or the default compression level if the column doesn't have a specific level specified. CompressionLevelPath is the same as CompressionLevelFor but takes a ColumnPath object CompressionPath is the same as CompressionFor but takes a ColumnPath(*WriterProperties) CreatedBy() string(*WriterProperties) DataPageSize() int64(*WriterProperties) DataPageVersion() DataPageVersion DictionaryCostFallbackEnabledFor returns whether the pre-first-page cost-based
dictionary fallback applies for the given column path: an explicit per-column
WithDictionaryCostFallbackFor setting wins, otherwise the fallback is enabled
only when the column is written without page compression, since the cost
comparison is done on uncompressed sizes. DictionaryEnabled returns the default value as for whether or not dictionary encoding will be utilized for columns
that aren't separately specified. DictionaryEnabledFor returns whether or not dictionary encoding will be used for the specified column when writing
or the default value if the column was not separately specified. DictionaryEnabledPath is the same as DictionaryEnabledFor but takes a ColumnPath object. DictionaryIndexEncoding returns which encoding will be used for the Dictionary Index values based on the
parquet version. V1 uses PlainDict and V2 uses RLEDict DictionaryPageEncoding returns the encoding that will be utilized for the DictionaryPage itself based on the parquet
version. V1 uses PlainDict, v2 uses Plain(*WriterProperties) DictionaryPageSizeLimit() int64 Encoding returns the default encoding that will be utilized for any columns which don't have a different value
specified. EncodingFor returns the encoding that will be used for the given column path, or the default encoding if there
isn't one specified for this column. EncodingPath is the same as EncodingFor but takes a ColumnPath object FileEncryptionProperties returns the current encryption properties that were
used to create the writer properties. MaxBloomFilterBytes returns the maximum number of bytes that a bloom filter can use(*WriterProperties) MaxRowGroupLength() int64 MaxStatsSize returns the default maximum size for stats MaxStatsSizeFor returns the maximum stat size for the given column path MaxStatsSizePath is the same as MaxStatsSizeFor but takes a ColumnPath PageIndexEnabled returns the default value for whether or not page indexes will be written PageIndexEnabledFor returns whether page index writing is enabled for the given column path, or
the default value if it wasn't specified separately. PageIndexEnabledPath is the same as PageIndexEnabledFor but takes a ColumnPath object(*WriterProperties) RootName() string(*WriterProperties) RootRepetition() Repetition(*WriterProperties) SortingColumns() []SortingColumn StatisticsEnabled returns the default value for whether or not stats are enabled to be written for columns
that aren't separately specified. StatisticsEnabledFor returns whether stats will be written for the given column path, or the default value if
it wasn't separately specified. StatisticsEnabledPath is the same as StatisticsEnabledFor but takes a ColumnPath object. StoreDecimalAsInteger returns the config option controlling whether or not
to try storing decimal data as an integer type if the precision is low enough
(1 <= prec <= 18 can be stored as an int), otherwise it will be stored as
a fixed len byte array.(*WriterProperties) Version() Version(*WriterProperties) WriteBatchSize() int64
func NewWriterProperties(opts ...WriterProperty) *WriterProperties
AlgorithmFromThrift converts the thrift object to the Algorithm struct for easier usage.
ColumnPathFromString constructs a ColumnPath from a dot separated string
DefaultColumnProperties returns the default properties which get utilized for writing.
The default column properties are the following constants:
Encoding: Encodings.Plain
Codec: compress.Codecs.Uncompressed
DictionaryEnabled: DefaultDictionaryEnabled
StatsEnabled: DefaultStatsEnabled
PageIndexEnabled: DefaultPageIndexEnabled
MaxStatsSize: DefaultMaxStatsSize
CompressionLevel: compress.DefaultCompressionLevel
BloomFilterEnabled: DefaultBloomFilterEnabled
BloomFilterFPP: DefaultBloomFilterFPP
AdaptiveBloomFilterEnabled: DefaultAdaptiveBloomFilterEnabled
BloomFilterCandidates: DefaultBloomFilterCandidates
DisableAadPrefixStorage will set the properties to not store the AadPrefix in the file. If this isn't called
and the AadPrefix is set, then it will be stored. This needs to in the options *after* WithAadPrefix to have an effect.
DisableFooterSignatureVerification skips integrity verification of plaintext footers.
If not called, integrity of plaintext footers will be checked in runtime, and will panic
if the footer signing key is not available
or if the footer content and signature don't match
NewColumnDecryptionProperties constructs a new ColumnDecryptionProperties for the given column path, modified by
the provided options
NewColumnEncryptionProperties constructs properties for the provided column path, modified by the options provided
NewFileDecryptionProperties takes in the options for constructing a new FileDecryptionProperties object, otherwise
it will use the default configuration which will check footer integrity of a plaintext footer for an encrypted file
for unencrypted parquet files, the decryption properties should not be set.
NewFileEncryptionProperties returns a new File Encryption description object using the options provided.
NewInt96 creates a new Int96 from the given 3 uint32 values.
NewReaderProperties returns the default Reader Properties using the provided allocator.
If nil is passed for the allocator, then memory.DefaultAllocator will be used.
NewWriterProperties takes a list of options for building the properties. If multiple options are used which conflict
then the last option is the one which will take effect. If no WriterProperty options are provided, then the default
properties will be utilized for writing.
The Default properties use the following constants:
Allocator: memory.DefaultAllocator
DictionaryPageSize: DefaultDictionaryPageSizeLimit
BatchSize: DefaultWriteBatchSize
MaxRowGroupLength: DefaultMaxRowGroupLen
PageSize: DefaultDataPageSize
ParquetVersion: V2_LATEST
DataPageVersion: DataPageV1
CreatedBy: DefaultCreatedBy
WithAadPrefix sets the AAD prefix to use for encryption and by default will store it in the file
WithAdaptiveBloomFilterEnabled sets the default value for whether to enable writing
adaptive bloom filters for columns. This is the default value for all columns,
but can be overridden by using WithAdaptiveBloomFilterEnabledFor or
WithAdaptiveBloomFilterEnabledPath.
Using an Adaptive Bloom filter will attempt to use multiple candidate bloom filters
when building the column, with different expected distinct values. It will attempt
to use the smallest candidate bloom filter that achieves the desired false positive
probability. Dropping candidates bloom filters that are no longer viable.
WithAdaptiveBloomFilterEnabledFor specifies a per column value as to enable or disable writing
adaptive bloom filters for the column.
WithAdaptiveBloomFilterEnabledPath is like WithAdaptiveBloomFilterEnabledFor, but takes a ColumnPath
WithAlg sets the encryption algorithm to utilize. (default is AesGcm)
WithAllocator specifies the writer to use the given allocator
WithALPEncoding permits all columns to use the preview ALP encoding. Readers
without ALP support cannot read files that use it, so ALP is disabled by
default.
The option grants permission rather than selecting ALP. A column still asks for
the encoding through WithEncodingFor or WithEncodingPath, and asking for it
without this option panics, as asking for any unusable encoding does.
ALP supports only FLOAT and DOUBLE columns. WithEncoding(Encodings.ALP) sets
it for every column, so writing any other column without a dictionary
(BOOLEAN and INT96 never use one) panics; prefer selecting it per column.
A column reaches ALP only with dictionary encoding turned off. A dictionary
takes precedence over the encoding a column asks for, and a writer that drops
the dictionary falls back to PLAIN rather than to ALP, so pair the request with
WithDictionaryDefault(false) or WithDictionaryFor(path, false).
WithALPEncodingFor overrides this setting for one column.
WithALPEncodingFor permits or rejects ALP for one column. See WithALPEncoding
for the requirements that apply when ALP is enabled.
WithALPEncodingPath is the same as WithALPEncodingFor but takes a ColumnPath.
WithALPVectorSize sets how many values each ALP vector holds for all
columns. It must be a power of two from 8 to 32768; the default is
DefaultALPVectorSize. Larger vectors amortize the per-vector header, while
smaller ones let each vector pick the scaling that suits its values.
It only affects columns written with the ALP encoding, and readers honor
whatever size a page declares.
WithALPVectorSizeFor sets the ALP vector size for one column. See
WithALPVectorSize.
WithALPVectorSizePath is the same as WithALPVectorSizeFor but takes a
ColumnPath.
WithBatchSize specifies the number of rows to use for batch writes to columns
WithBloomFilterCandidates sets the number of candidate bloom filters to use when building
an adaptive bloom filter.
WithBloomFilterCandidatesFor specifies a per column value for the number of candidate
bloom filters to use when building an adaptive bloom filter.
WithBloomFilterCandidatesPath is like WithBloomFilterCandidatesFor, but takes a ColumnPath
WithBloomFilterEnabled sets the default value for whether to enable writing bloom
filters for columns. This is the default value for all columns, but can be overridden
by using WithBloomFilterEnabledFor or WithBloomFilterEnabledPath.
WithBloomFilterEnabledFor specifies a per column value as to enable or disable writing
bloom filters for the column.
WithBloomFilterEnabledPath is like WithBloomFilterEnabledFor, but takes a ColumnPath
WithBloomFilterFPP sets the default value for the false positive probability for writing
bloom filters.
WithBloomFilterFPPFor specifies a per column value for the false positive probability
for writing bloom filters.
WithBloomFilterFPPPath is like WithBloomFilterFPPFor, but takes a ColumnPath
WithBloomFilterNDV sets the default value for the expected number of distinct values
to be written for the column. This is ignored when using adaptive bloom filters.
WithBloomFilterNDVFor specifies a per column value for the expected number of distinct values
to be written for the column. This is ignored when using adaptive bloom filters.
WithBloomFilterNDVPath is like WithBloomFilterNDVFor, but takes a ColumnPath
WithColumnKeys sets explicit column keys.
It's also possible to set a key retriever on this property object.
Upon file decryption, availability of explicit keys is checked before invocation
of the retriever callback.
If an explicit key is available for a footer or a column, its key metadata will be ignored.
WithCompression specifies the default compression type to use for column writing.
WithCompressionFor specifies the compression type for the given column.
WithCompressionLevel specifies the default compression level for the compressor in every column.
The provided compression level is compressor specific. The user would have to know what the available
levels are for the selected compressor. If the compressor does not allow for selecting different
compression levels, then this function will have no effect. Parquet and Arrow will not validate the
passed compression level. If no level is selected by the user or if the special compress.DefaultCompressionLevel
value is used, then parquet will select the compression level.
WithCompressionLevelFor is like WithCompressionLevel but only for the given column path.
WithCompressionLevelPath is the same as WithCompressionLevelFor but takes a ColumnPath
WithCompressionPath is the same as WithCompressionFor but takes a ColumnPath directly.
WithCreatedBy specifies the "created by" string to use for the writer
WithDataPageSize specifies the size to use for splitting data pages for column writing.
WithDataPageVersion specifies whether to use Version 1 or Version 2 of the DataPage spec
WithDecryptAadPrefix explicitly supplies the file aad prefix.
A must when a prefix is used for file encryption, but not stored in the file.
WithDecryptKey specifies the key to utilize for decryption
WithDictionaryCostFallbackFor controls the cost-based dictionary fallback for the
given column path: before the first data page of a column chunk is cut, the writer
discards the dictionary and falls back to the plain encoding when the dictionary
plus the encoded indices are not smaller than the raw values (mirroring
parquet-mr's shouldFallBack). That comparison is done on uncompressed sizes, so by
default it only runs for columns written without page compression — for columns
with a codec configured the dictionary is kept, since near-incompressible
dictionary indices routinely beat plain pages that compress well. This option
overrides the codec-based default in either direction: false keeps an explicitly
requested dictionary for an uncompressed column, true forces the check for a
compressed one. The DictionaryPageSizeLimit fallback always stays in effect.
WithDictionaryCostFallbackPath is like WithDictionaryCostFallbackFor, but takes
a ColumnPath type.
WithDictionaryDefault sets the default value for whether to enable dictionary encoding
WithDictionaryFor allows enabling or disabling dictionary encoding for a given column path string
WithDictionaryPageSizeLimit is the limit of the dictionary at which the writer
will fallback to plain encoding instead
WithDictionaryPath is like WithDictionaryFor, but takes a ColumnPath type
WithEncoding defines the encoding that is used when we aren't using dictionary encoding.
This is either applied if dictionary encoding is disabled, or if we fallback if the dictionary
grew too large.
WithEncodingFor is for defining the encoding only for a specific column path. This encoding will be used
if dictionary encoding is disabled for the column or if we fallback because the dictionary grew too large
WithEncodingPath is the same as WithEncodingFor but takes a ColumnPath directly.
WithEncryptedColumns sets the map of columns and their properties (keys etc.) If not called, then all columns will
be encrypted with the footer key. If called, then columns not in the map will be left unencrypted.
WithEncryptionProperties specifies the file level encryption handling for writing the file.
WithFooterKey sets an explicit footer key. If Applied on a file that contains footer key
metadata the metadata will be ignored, the footer will be decrypted/verified with this key.
If the explicit key is not set, footer key will be fetched from the key retriever.
With explicit keys or AAD prefix, new encryption properties object must be created for each
encrypted file.
Explicit encryption keys (footer and column) are cloned.
Upon completion of file reading, the cloned encryption keys in the properties will be wiped out
Caller is responsible for wiping out the input key array
footer key length must be either 16, 24, or 32 bytes
WithFooterKeyID sets a key retrieval metadata to use (converted from string), this must be a utf8 string.
use either WithFooterKeyID or WithFooterKeyMetadata, not both.
WithFooterKeyMetadata sets a key retrieval metadata to use for getting the key.
Use either WithFooterKeyID or WithFooterKeyMetadata, not both.
WithKey sets a column specific key.
If key is not set on an encrypted column, the column will be encrypted with the footer key.
key length must be either 16, 24, or 32 bytes
the key is cloned and will be wiped out (array values set to 0) upon completion of file writing.
Caller is responsible for wiping out input key array
WithKeyID is a convenience function to set the key metadata using a string id.
Set a key retrieval metadata (converted from String). and use either KeyMetadata or KeyID, not both.
KeyID will be converted to metadata (UTF-8 Array)
WithKeyMetadata sets the key retrieval metadata, use either KeyMetadata or KeyID but not both
WithKeyRetriever sets a key retriever callback. It's also possible to set explicit footer or column keys.
WithMaxBloomFilterBytes sets the maximum size for a bloom filter, after which
it is abandoned and not written to the file.
WithMaxRowGroupLength specifies the number of rows as the maximum number of rows for a given row group in the writer.
WithMaxStatsSize sets a maximum size for the statistics before we decide not to include them.
WithPageIndexEnabled specifies the default value for whether or not to write page indexes for columns
WithPageIndexEnabled specifies a per column value as to enable or disable writing page indexes for the column
WithPageIndexEnabledPath is like WithPageIndexEnabledFor, but takes a ColumnPath
WithPlaintextAllowed sets allowing plaintext files.
By default, reading plaintext (unencrypted) files is not allowed when using
a decryptor.
In order to detect files that were not encrypted by mistake.
However the default behavior can be overridden by using this method.
WithPlaintextFooter sets the writer to write the footer in plain text, otherwise the footer will be encrypted
too (which is the default behavior).
WithPrefixVerifier supplies a verifier object to use for verifying the AAD Prefixes stored in the file.
WithRootName enables customization of the name used for the root schema node. This is required
to maintain compatibility with other tools.
WithRootRepetition enables customization of the repetition used for the root schema node.
This is required to maintain compatibility with other tools.
WithSortingColumns allow specifying the sorting columns in the written metadata.
If this is set, the user should ensure that records are sorted by these columns,
otherwise the sorting data will be inconsistent with the sorting_columns metadata.
WithStats specifies a default for whether or not to enable column statistics.
WithStatsFor specifies a per column value as to enable or disable statistics in the resulting file.
WithStatsPath is the same as WithStatsFor but takes a ColumnPath
WithStoreDecimalAsInteger specifies whether to try using an int32/int64 for storing
decimal data rather than fixed len byte arrays if the precision is low enough.
WithVersion specifies which Parquet Spec version to utilize for writing.
Package-Level Variables (total 10)
ByteArraySizeBytes is the number of bytes returned by reflect.TypeOf(ByteArray{}).Size()
ByteArrayTraits provides information about the ByteArray type, which is just an []byte
ColumnOrders contains constants for the Column Ordering fields
DefaultColumnOrder is to use TypeDefinedOrder
Encodings contains constants for the encoding types of the column data
The values used all correspond to the values in parquet.thrift for the
corresponding encoding type.
FixedLenByteArraySizeBytes is the number of bytes returned by reflect.TypeOf(FixedLenByteArray{}).Size()
FixedLenByteArrayTraits provides information about the FixedLenByteArray type which is just an []byte
Int96Traits provides information about the Int96 type
Repetitions contains the constants for Field Repetition Types
Types contains constants for the Physical Types that are used in the Parquet Spec
They can be specified when needed as such: `parquet.Types.Int32` etc. The values
all correspond to the values in parquet.thrift
Package-Level Constants (total 35)
Constants that will be used as the default values with encryption/decryption
constants for choosing the Aes Algorithm to use for encryption/decryption
constants for choosing the Aes Algorithm to use for encryption/decryption
constants for the parquet DataPage Version to use
constants for the parquet DataPage Version to use
Constants for default property values used for the default reader, writer and column props.
by default if you set the file decryption properties, we will error
on any plaintext files unless otherwise specified.
DefaultALPEnabled is false because ALP is a preview encoding.
DefaultALPVectorSize is how many values an ALP vector holds unless
WithALPVectorSize says otherwise.
Constants for default property values used for the default reader, writer and column props.
Constants for default property values used for the default reader, writer and column props.
Constants for default property values used for the default reader, writer and column props.
Default Buffer size used for the Reader
Constants that will be used as the default values with encryption/decryption
Constants for default property values used for the default reader, writer and column props.
Default data page size limit is 1M, it's not guaranteed, but we will try to
cut data pages off at this size where possible.
Default is for dictionary encoding to be turned on, use WithDictionaryDefault
writer property to change that.
If the dictionary reaches the size of this limitation, the writer will use
the fallback encoding (usually plain) instead of continuing to build the
dictionary index.
if encryption is turned on, we will default to also encrypting the footer
By default we'll use AesGCM as our encryption algorithm
Constants for default property values used for the default reader, writer and column props.
DefaultMaxCompressedPageSize is the largest compressed page body accepted
by readers created with NewReaderProperties.
Default maximum number of rows for a single row group
If the stats are larger than 4K the writer will skip writing them out anyways.
DefaultMaxUncompressedPageSize is the largest uncompressed page body
accepted by readers created with NewReaderProperties.
Default is to not write page indexes for columns
Constants for default property values used for the default reader, writer and column props.
Default is to have stats enabled for all columns, use writer properties to
change the default, or to enable/disable for specific columns.
In order to attempt to facilitate data page size limits for writing,
data is written in batches. Increasing the batch size may improve performance
but the larger the batch size, the easier it is to overshoot the datapage limit.
Int96SizeBytes is the number of bytes that make up an Int96
Constants that will be used as the default values with encryption/decryption
Enable only pre-2.2 parquet format features when writing.
This is useful for maximum compatibility with legacy readers.
Note that logical types may still be emitted, as long as they have
a corresponding converted type.
Enable parquet format 2.4 and earlier features when writing.
This enables uint32 as well as logical types which don't have a
corresponding converted type.
Note: Parquet format 2.4.0 was released in October 2017
Enable Parquet format 2.6 and earlier features when writing.
This enables the nanos time unit in addition to the V2_4 features.
Note: Parquet format 2.6.0 was released in September 2018
Enable the latest parquet format 2.x features.
This is equal to the greatest 2.x version supported by this library.
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.