github.com/fraugster/parquet-go@v0.12.0/parquet/parquet.thrift (about) 1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20 /** 21 * File format description for the parquet file format 22 */ 23 namespace cpp parquet 24 namespace java org.apache.parquet.format 25 26 /** 27 * Types supported by Parquet. These types are intended to be used in combination 28 * with the encodings to control the on disk storage format. 29 * For example INT16 is not included as a type since a good encoding of INT32 30 * would handle this. 31 */ 32 enum Type { 33 BOOLEAN = 0; 34 INT32 = 1; 35 INT64 = 2; 36 INT96 = 3; // deprecated, only used by legacy implementations. 37 FLOAT = 4; 38 DOUBLE = 5; 39 BYTE_ARRAY = 6; 40 FIXED_LEN_BYTE_ARRAY = 7; 41 } 42 43 /** 44 * DEPRECATED: Common types used by frameworks(e.g. hive, pig) using parquet. 45 * ConvertedType is superseded by LogicalType. This enum should not be extended. 46 * 47 * See LogicalTypes.md for conversion between ConvertedType and LogicalType. 48 */ 49 enum ConvertedType { 50 /** a BYTE_ARRAY actually contains UTF8 encoded chars */ 51 UTF8 = 0; 52 53 /** a map is converted as an optional field containing a repeated key/value pair */ 54 MAP = 1; 55 56 /** a key/value pair is converted into a group of two fields */ 57 MAP_KEY_VALUE = 2; 58 59 /** a list is converted into an optional field containing a repeated field for its 60 * values */ 61 LIST = 3; 62 63 /** an enum is converted into a binary field */ 64 ENUM = 4; 65 66 /** 67 * A decimal value. 68 * 69 * This may be used to annotate binary or fixed primitive types. The 70 * underlying byte array stores the unscaled value encoded as two's 71 * complement using big-endian byte order (the most significant byte is the 72 * zeroth element). The value of the decimal is the value * 10^{-scale}. 73 * 74 * This must be accompanied by a (maximum) precision and a scale in the 75 * SchemaElement. The precision specifies the number of digits in the decimal 76 * and the scale stores the location of the decimal point. For example 1.23 77 * would have precision 3 (3 total digits) and scale 2 (the decimal point is 78 * 2 digits over). 79 */ 80 DECIMAL = 5; 81 82 /** 83 * A Date 84 * 85 * Stored as days since Unix epoch, encoded as the INT32 physical type. 86 * 87 */ 88 DATE = 6; 89 90 /** 91 * A time 92 * 93 * The total number of milliseconds since midnight. The value is stored 94 * as an INT32 physical type. 95 */ 96 TIME_MILLIS = 7; 97 98 /** 99 * A time. 100 * 101 * The total number of microseconds since midnight. The value is stored as 102 * an INT64 physical type. 103 */ 104 TIME_MICROS = 8; 105 106 /** 107 * A date/time combination 108 * 109 * Date and time recorded as milliseconds since the Unix epoch. Recorded as 110 * a physical type of INT64. 111 */ 112 TIMESTAMP_MILLIS = 9; 113 114 /** 115 * A date/time combination 116 * 117 * Date and time recorded as microseconds since the Unix epoch. The value is 118 * stored as an INT64 physical type. 119 */ 120 TIMESTAMP_MICROS = 10; 121 122 123 /** 124 * An unsigned integer value. 125 * 126 * The number describes the maximum number of meaningful data bits in 127 * the stored value. 8, 16 and 32 bit values are stored using the 128 * INT32 physical type. 64 bit values are stored using the INT64 129 * physical type. 130 * 131 */ 132 UINT_8 = 11; 133 UINT_16 = 12; 134 UINT_32 = 13; 135 UINT_64 = 14; 136 137 /** 138 * A signed integer value. 139 * 140 * The number describes the maximum number of meaningful data bits in 141 * the stored value. 8, 16 and 32 bit values are stored using the 142 * INT32 physical type. 64 bit values are stored using the INT64 143 * physical type. 144 * 145 */ 146 INT_8 = 15; 147 INT_16 = 16; 148 INT_32 = 17; 149 INT_64 = 18; 150 151 /** 152 * An embedded JSON document 153 * 154 * A JSON document embedded within a single UTF8 column. 155 */ 156 JSON = 19; 157 158 /** 159 * An embedded BSON document 160 * 161 * A BSON document embedded within a single BINARY column. 162 */ 163 BSON = 20; 164 165 /** 166 * An interval of time 167 * 168 * This type annotates data stored as a FIXED_LEN_BYTE_ARRAY of length 12 169 * This data is composed of three separate little endian unsigned 170 * integers. Each stores a component of a duration of time. The first 171 * integer identifies the number of months associated with the duration, 172 * the second identifies the number of days associated with the duration 173 * and the third identifies the number of milliseconds associated with 174 * the provided duration. This duration of time is independent of any 175 * particular timezone or date. 176 */ 177 INTERVAL = 21; 178 } 179 180 /** 181 * Representation of Schemas 182 */ 183 enum FieldRepetitionType { 184 /** This field is required (can not be null) and each record has exactly 1 value. */ 185 REQUIRED = 0; 186 187 /** The field is optional (can be null) and each record has 0 or 1 values. */ 188 OPTIONAL = 1; 189 190 /** The field is repeated and can contain 0 or more values */ 191 REPEATED = 2; 192 } 193 194 /** 195 * Statistics per row group and per page 196 * All fields are optional. 197 */ 198 struct Statistics { 199 /** 200 * DEPRECATED: min and max value of the column. Use min_value and max_value. 201 * 202 * Values are encoded using PLAIN encoding, except that variable-length byte 203 * arrays do not include a length prefix. 204 * 205 * These fields encode min and max values determined by signed comparison 206 * only. New files should use the correct order for a column's logical type 207 * and store the values in the min_value and max_value fields. 208 * 209 * To support older readers, these may be set when the column order is 210 * signed. 211 */ 212 1: optional binary max; 213 2: optional binary min; 214 /** count of null value in the column */ 215 3: optional i64 null_count; 216 /** count of distinct values occurring */ 217 4: optional i64 distinct_count; 218 /** 219 * Min and max values for the column, determined by its ColumnOrder. 220 * 221 * Values are encoded using PLAIN encoding, except that variable-length byte 222 * arrays do not include a length prefix. 223 */ 224 5: optional binary max_value; 225 6: optional binary min_value; 226 } 227 228 /** Empty structs to use as logical type annotations */ 229 struct StringType {} // allowed for BINARY, must be encoded with UTF-8 230 struct UUIDType {} // allowed for FIXED[16], must encoded raw UUID bytes 231 struct MapType {} // see LogicalTypes.md 232 struct ListType {} // see LogicalTypes.md 233 struct EnumType {} // allowed for BINARY, must be encoded with UTF-8 234 struct DateType {} // allowed for INT32 235 236 /** 237 * Logical type to annotate a column that is always null. 238 * 239 * Sometimes when discovering the schema of existing data, values are always 240 * null and the physical type can't be determined. This annotation signals 241 * the case where the physical type was guessed from all null values. 242 */ 243 struct NullType {} // allowed for any physical type, only null values stored 244 245 /** 246 * Decimal logical type annotation 247 * 248 * To maintain forward-compatibility in v1, implementations using this logical 249 * type must also set scale and precision on the annotated SchemaElement. 250 * 251 * Allowed for physical types: INT32, INT64, FIXED, and BINARY 252 */ 253 struct DecimalType { 254 1: required i32 scale 255 2: required i32 precision 256 } 257 258 /** Time units for logical types */ 259 struct MilliSeconds {} 260 struct MicroSeconds {} 261 struct NanoSeconds {} 262 union TimeUnit { 263 1: MilliSeconds MILLIS 264 2: MicroSeconds MICROS 265 3: NanoSeconds NANOS 266 } 267 268 /** 269 * Timestamp logical type annotation 270 * 271 * Allowed for physical types: INT64 272 */ 273 struct TimestampType { 274 1: required bool isAdjustedToUTC 275 2: required TimeUnit unit 276 } 277 278 /** 279 * Time logical type annotation 280 * 281 * Allowed for physical types: INT32 (millis), INT64 (micros, nanos) 282 */ 283 struct TimeType { 284 1: required bool isAdjustedToUTC 285 2: required TimeUnit unit 286 } 287 288 /** 289 * Integer logical type annotation 290 * 291 * bitWidth must be 8, 16, 32, or 64. 292 * 293 * Allowed for physical types: INT32, INT64 294 */ 295 struct IntType { 296 1: required i8 bitWidth 297 2: required bool isSigned 298 } 299 300 /** 301 * Embedded JSON logical type annotation 302 * 303 * Allowed for physical types: BINARY 304 */ 305 struct JsonType { 306 } 307 308 /** 309 * Embedded BSON logical type annotation 310 * 311 * Allowed for physical types: BINARY 312 */ 313 struct BsonType { 314 } 315 316 /** 317 * LogicalType annotations to replace ConvertedType. 318 * 319 * To maintain compatibility, implementations using LogicalType for a 320 * SchemaElement must also set the corresponding ConvertedType (if any) 321 * from the following table. 322 */ 323 union LogicalType { 324 1: StringType STRING // use ConvertedType UTF8 325 2: MapType MAP // use ConvertedType MAP 326 3: ListType LIST // use ConvertedType LIST 327 4: EnumType ENUM // use ConvertedType ENUM 328 5: DecimalType DECIMAL // use ConvertedType DECIMAL + SchemaElement.{scale, precision} 329 6: DateType DATE // use ConvertedType DATE 330 331 // use ConvertedType TIME_MICROS for TIME(isAdjustedToUTC = *, unit = MICROS) 332 // use ConvertedType TIME_MILLIS for TIME(isAdjustedToUTC = *, unit = MILLIS) 333 7: TimeType TIME 334 335 // use ConvertedType TIMESTAMP_MICROS for TIMESTAMP(isAdjustedToUTC = *, unit = MICROS) 336 // use ConvertedType TIMESTAMP_MILLIS for TIMESTAMP(isAdjustedToUTC = *, unit = MILLIS) 337 8: TimestampType TIMESTAMP 338 339 // 9: reserved for INTERVAL 340 10: IntType INTEGER // use ConvertedType INT_* or UINT_* 341 11: NullType UNKNOWN // no compatible ConvertedType 342 12: JsonType JSON // use ConvertedType JSON 343 13: BsonType BSON // use ConvertedType BSON 344 14: UUIDType UUID // no compatible ConvertedType 345 } 346 347 /** 348 * Represents a element inside a schema definition. 349 * - if it is a group (inner node) then type is undefined and num_children is defined 350 * - if it is a primitive type (leaf) then type is defined and num_children is undefined 351 * the nodes are listed in depth first traversal order. 352 */ 353 struct SchemaElement { 354 /** Data type for this field. Not set if the current element is a non-leaf node */ 355 1: optional Type type; 356 357 /** If type is FIXED_LEN_BYTE_ARRAY, this is the byte length of the vales. 358 * Otherwise, if specified, this is the maximum bit length to store any of the values. 359 * (e.g. a low cardinality INT col could have this set to 3). Note that this is 360 * in the schema, and therefore fixed for the entire file. 361 */ 362 2: optional i32 type_length; 363 364 /** repetition of the field. The root of the schema does not have a repetition_type. 365 * All other nodes must have one */ 366 3: optional FieldRepetitionType repetition_type; 367 368 /** Name of the field in the schema */ 369 4: required string name; 370 371 /** Nested fields. Since thrift does not support nested fields, 372 * the nesting is flattened to a single list by a depth-first traversal. 373 * The children count is used to construct the nested relationship. 374 * This field is not set when the element is a primitive type 375 */ 376 5: optional i32 num_children; 377 378 /** 379 * DEPRECATED: When the schema is the result of a conversion from another model. 380 * Used to record the original type to help with cross conversion. 381 * 382 * This is superseded by logicalType. 383 */ 384 6: optional ConvertedType converted_type; 385 386 /** 387 * DEPRECATED: Used when this column contains decimal data. 388 * See the DECIMAL converted type for more details. 389 * 390 * This is superseded by using the DecimalType annotation in logicalType. 391 */ 392 7: optional i32 scale 393 8: optional i32 precision 394 395 /** When the original schema supports field ids, this will save the 396 * original field id in the parquet schema 397 */ 398 9: optional i32 field_id; 399 400 /** 401 * The logical type of this SchemaElement 402 * 403 * LogicalType replaces ConvertedType, but ConvertedType is still required 404 * for some logical types to ensure forward-compatibility in format v1. 405 */ 406 10: optional LogicalType logicalType 407 } 408 409 /** 410 * Encodings supported by Parquet. Not all encodings are valid for all types. These 411 * enums are also used to specify the encoding of definition and repetition levels. 412 * See the accompanying doc for the details of the more complicated encodings. 413 */ 414 enum Encoding { 415 /** Default encoding. 416 * BOOLEAN - 1 bit per value. 0 is false; 1 is true. 417 * INT32 - 4 bytes per value. Stored as little-endian. 418 * INT64 - 8 bytes per value. Stored as little-endian. 419 * FLOAT - 4 bytes per value. IEEE. Stored as little-endian. 420 * DOUBLE - 8 bytes per value. IEEE. Stored as little-endian. 421 * BYTE_ARRAY - 4 byte length stored as little endian, followed by bytes. 422 * FIXED_LEN_BYTE_ARRAY - Just the bytes. 423 */ 424 PLAIN = 0; 425 426 /** Group VarInt encoding for INT32/INT64. 427 * This encoding is deprecated. It was never used 428 */ 429 // GROUP_VAR_INT = 1; 430 431 /** 432 * Deprecated: Dictionary encoding. The values in the dictionary are encoded in the 433 * plain type. 434 * in a data page use RLE_DICTIONARY instead. 435 * in a Dictionary page use PLAIN instead 436 */ 437 PLAIN_DICTIONARY = 2; 438 439 /** Group packed run length encoding. Usable for definition/repetition levels 440 * encoding and Booleans (on one bit: 0 is false; 1 is true.) 441 */ 442 RLE = 3; 443 444 /** Bit packed encoding. This can only be used if the data has a known max 445 * width. Usable for definition/repetition levels encoding. 446 */ 447 BIT_PACKED = 4; 448 449 /** Delta encoding for integers. This can be used for int columns and works best 450 * on sorted data 451 */ 452 DELTA_BINARY_PACKED = 5; 453 454 /** Encoding for byte arrays to separate the length values and the data. The lengths 455 * are encoded using DELTA_BINARY_PACKED 456 */ 457 DELTA_LENGTH_BYTE_ARRAY = 6; 458 459 /** Incremental-encoded byte array. Prefix lengths are encoded using DELTA_BINARY_PACKED. 460 * Suffixes are stored as delta length byte arrays. 461 */ 462 DELTA_BYTE_ARRAY = 7; 463 464 /** Dictionary encoding: the ids are encoded using the RLE encoding 465 */ 466 RLE_DICTIONARY = 8; 467 468 /** Encoding for floating-point data. 469 K byte-streams are created where K is the size in bytes of the data type. 470 The individual bytes of an FP value are scattered to the corresponding stream and 471 the streams are concatenated. 472 This itself does not reduce the size of the data but can lead to better compression 473 afterwards. 474 */ 475 BYTE_STREAM_SPLIT = 9; 476 } 477 478 /** 479 * Supported compression algorithms. 480 * 481 * Codecs added in format version X.Y can be read by readers based on X.Y and later. 482 * Codec support may vary between readers based on the format version and 483 * libraries available at runtime. 484 * 485 * See Compression.md for a detailed specification of these algorithms. 486 */ 487 enum CompressionCodec { 488 UNCOMPRESSED = 0; 489 SNAPPY = 1; 490 GZIP = 2; 491 LZO = 3; 492 BROTLI = 4; // Added in 2.4 493 LZ4 = 5; // DEPRECATED (Added in 2.4) 494 ZSTD = 6; // Added in 2.4 495 LZ4_RAW = 7; // Added in 2.9 496 } 497 498 enum PageType { 499 DATA_PAGE = 0; 500 INDEX_PAGE = 1; 501 DICTIONARY_PAGE = 2; 502 DATA_PAGE_V2 = 3; 503 } 504 505 /** 506 * Enum to annotate whether lists of min/max elements inside ColumnIndex 507 * are ordered and if so, in which direction. 508 */ 509 enum BoundaryOrder { 510 UNORDERED = 0; 511 ASCENDING = 1; 512 DESCENDING = 2; 513 } 514 515 /** Data page header */ 516 struct DataPageHeader { 517 /** Number of values, including NULLs, in this data page. **/ 518 1: required i32 num_values 519 520 /** Encoding used for this data page **/ 521 2: required Encoding encoding 522 523 /** Encoding used for definition levels **/ 524 3: required Encoding definition_level_encoding; 525 526 /** Encoding used for repetition levels **/ 527 4: required Encoding repetition_level_encoding; 528 529 /** Optional statistics for the data in this page**/ 530 5: optional Statistics statistics; 531 } 532 533 struct IndexPageHeader { 534 // TODO 535 } 536 537 struct DictionaryPageHeader { 538 /** Number of values in the dictionary **/ 539 1: required i32 num_values; 540 541 /** Encoding using this dictionary page **/ 542 2: required Encoding encoding 543 544 /** If true, the entries in the dictionary are sorted in ascending order **/ 545 3: optional bool is_sorted; 546 } 547 548 /** 549 * New page format allowing reading levels without decompressing the data 550 * Repetition and definition levels are uncompressed 551 * The remaining section containing the data is compressed if is_compressed is true 552 **/ 553 struct DataPageHeaderV2 { 554 /** Number of values, including NULLs, in this data page. **/ 555 1: required i32 num_values 556 /** Number of NULL values, in this data page. 557 Number of non-null = num_values - num_nulls which is also the number of values in the data section **/ 558 2: required i32 num_nulls 559 /** Number of rows in this data page. which means pages change on record boundaries (r = 0) **/ 560 3: required i32 num_rows 561 /** Encoding used for data in this page **/ 562 4: required Encoding encoding 563 564 // repetition levels and definition levels are always using RLE (without size in it) 565 566 /** length of the definition levels */ 567 5: required i32 definition_levels_byte_length; 568 /** length of the repetition levels */ 569 6: required i32 repetition_levels_byte_length; 570 571 /** whether the values are compressed. 572 Which means the section of the page between 573 definition_levels_byte_length + repetition_levels_byte_length + 1 and compressed_page_size (included) 574 is compressed with the compression_codec. 575 If missing it is considered compressed */ 576 7: optional bool is_compressed = 1; 577 578 /** optional statistics for the data in this page **/ 579 8: optional Statistics statistics; 580 } 581 582 /** Block-based algorithm type annotation. **/ 583 struct SplitBlockAlgorithm {} 584 /** The algorithm used in Bloom filter. **/ 585 union BloomFilterAlgorithm { 586 /** Block-based Bloom filter. **/ 587 1: SplitBlockAlgorithm BLOCK; 588 } 589 590 /** Hash strategy type annotation. xxHash is an extremely fast non-cryptographic hash 591 * algorithm. It uses 64 bits version of xxHash. 592 **/ 593 struct XxHash {} 594 595 /** 596 * The hash function used in Bloom filter. This function takes the hash of a column value 597 * using plain encoding. 598 **/ 599 union BloomFilterHash { 600 /** xxHash Strategy. **/ 601 1: XxHash XXHASH; 602 } 603 604 /** 605 * The compression used in the Bloom filter. 606 **/ 607 struct Uncompressed {} 608 union BloomFilterCompression { 609 1: Uncompressed UNCOMPRESSED; 610 } 611 612 /** 613 * Bloom filter header is stored at beginning of Bloom filter data of each column 614 * and followed by its bitset. 615 **/ 616 struct BloomFilterHeader { 617 /** The size of bitset in bytes **/ 618 1: required i32 numBytes; 619 /** The algorithm for setting bits. **/ 620 2: required BloomFilterAlgorithm algorithm; 621 /** The hash function used for Bloom filter. **/ 622 3: required BloomFilterHash hash; 623 /** The compression used in the Bloom filter **/ 624 4: required BloomFilterCompression compression; 625 } 626 627 struct PageHeader { 628 /** the type of the page: indicates which of the *_header fields is set **/ 629 1: required PageType type 630 631 /** Uncompressed page size in bytes (not including this header) **/ 632 2: required i32 uncompressed_page_size 633 634 /** Compressed (and potentially encrypted) page size in bytes, not including this header **/ 635 3: required i32 compressed_page_size 636 637 /** The 32bit CRC for the page, to be be calculated as follows: 638 * - Using the standard CRC32 algorithm 639 * - On the data only, i.e. this header should not be included. 'Data' 640 * hereby refers to the concatenation of the repetition levels, the 641 * definition levels and the column value, in this exact order. 642 * - On the encoded versions of the repetition levels, definition levels and 643 * column values 644 * - On the compressed versions of the repetition levels, definition levels 645 * and column values where possible; 646 * - For v1 data pages, the repetition levels, definition levels and column 647 * values are always compressed together. If a compression scheme is 648 * specified, the CRC shall be calculated on the compressed version of 649 * this concatenation. If no compression scheme is specified, the CRC 650 * shall be calculated on the uncompressed version of this concatenation. 651 * - For v2 data pages, the repetition levels and definition levels are 652 * handled separately from the data and are never compressed (only 653 * encoded). If a compression scheme is specified, the CRC shall be 654 * calculated on the concatenation of the uncompressed repetition levels, 655 * uncompressed definition levels and the compressed column values. 656 * If no compression scheme is specified, the CRC shall be calculated on 657 * the uncompressed concatenation. 658 * - In encrypted columns, CRC is calculated after page encryption; the 659 * encryption itself is performed after page compression (if compressed) 660 * If enabled, this allows for disabling checksumming in HDFS if only a few 661 * pages need to be read. 662 **/ 663 4: optional i32 crc 664 665 // Headers for page specific data. One only will be set. 666 5: optional DataPageHeader data_page_header; 667 6: optional IndexPageHeader index_page_header; 668 7: optional DictionaryPageHeader dictionary_page_header; 669 8: optional DataPageHeaderV2 data_page_header_v2; 670 } 671 672 /** 673 * Wrapper struct to store key values 674 */ 675 struct KeyValue { 676 1: required string key 677 2: optional string value 678 } 679 680 /** 681 * Wrapper struct to specify sort order 682 */ 683 struct SortingColumn { 684 /** The column index (in this row group) **/ 685 1: required i32 column_idx 686 687 /** If true, indicates this column is sorted in descending order. **/ 688 2: required bool descending 689 690 /** If true, nulls will come before non-null values, otherwise, 691 * nulls go at the end. */ 692 3: required bool nulls_first 693 } 694 695 /** 696 * statistics of a given page type and encoding 697 */ 698 struct PageEncodingStats { 699 700 /** the page type (data/dic/...) **/ 701 1: required PageType page_type; 702 703 /** encoding of the page **/ 704 2: required Encoding encoding; 705 706 /** number of pages of this type with this encoding **/ 707 3: required i32 count; 708 709 } 710 711 /** 712 * Description for column metadata 713 */ 714 struct ColumnMetaData { 715 /** Type of this column **/ 716 1: required Type type 717 718 /** Set of all encodings used for this column. The purpose is to validate 719 * whether we can decode those pages. **/ 720 2: required list<Encoding> encodings 721 722 /** Path in schema **/ 723 3: required list<string> path_in_schema 724 725 /** Compression codec **/ 726 4: required CompressionCodec codec 727 728 /** Number of values in this column **/ 729 5: required i64 num_values 730 731 /** total byte size of all uncompressed pages in this column chunk (including the headers) **/ 732 6: required i64 total_uncompressed_size 733 734 /** total byte size of all compressed, and potentially encrypted, pages 735 * in this column chunk (including the headers) **/ 736 7: required i64 total_compressed_size 737 738 /** Optional key/value metadata **/ 739 8: optional list<KeyValue> key_value_metadata 740 741 /** Byte offset from beginning of file to first data page **/ 742 9: required i64 data_page_offset 743 744 /** Byte offset from beginning of file to root index page **/ 745 10: optional i64 index_page_offset 746 747 /** Byte offset from the beginning of file to first (only) dictionary page **/ 748 11: optional i64 dictionary_page_offset 749 750 /** optional statistics for this column chunk */ 751 12: optional Statistics statistics; 752 753 /** Set of all encodings used for pages in this column chunk. 754 * This information can be used to determine if all data pages are 755 * dictionary encoded for example **/ 756 13: optional list<PageEncodingStats> encoding_stats; 757 758 /** Byte offset from beginning of file to Bloom filter data. **/ 759 14: optional i64 bloom_filter_offset; 760 } 761 762 struct EncryptionWithFooterKey { 763 } 764 765 struct EncryptionWithColumnKey { 766 /** Column path in schema **/ 767 1: required list<string> path_in_schema 768 769 /** Retrieval metadata of column encryption key **/ 770 2: optional binary key_metadata 771 } 772 773 union ColumnCryptoMetaData { 774 1: EncryptionWithFooterKey ENCRYPTION_WITH_FOOTER_KEY 775 2: EncryptionWithColumnKey ENCRYPTION_WITH_COLUMN_KEY 776 } 777 778 struct ColumnChunk { 779 /** File where column data is stored. If not set, assumed to be same file as 780 * metadata. This path is relative to the current file. 781 **/ 782 1: optional string file_path 783 784 /** Byte offset in file_path to the ColumnMetaData **/ 785 2: required i64 file_offset 786 787 /** Column metadata for this chunk. This is the same content as what is at 788 * file_path/file_offset. Having it here has it replicated in the file 789 * metadata. 790 **/ 791 3: optional ColumnMetaData meta_data 792 793 /** File offset of ColumnChunk's OffsetIndex **/ 794 4: optional i64 offset_index_offset 795 796 /** Size of ColumnChunk's OffsetIndex, in bytes **/ 797 5: optional i32 offset_index_length 798 799 /** File offset of ColumnChunk's ColumnIndex **/ 800 6: optional i64 column_index_offset 801 802 /** Size of ColumnChunk's ColumnIndex, in bytes **/ 803 7: optional i32 column_index_length 804 805 /** Crypto metadata of encrypted columns **/ 806 8: optional ColumnCryptoMetaData crypto_metadata 807 808 /** Encrypted column metadata for this chunk **/ 809 9: optional binary encrypted_column_metadata 810 } 811 812 struct RowGroup { 813 /** Metadata for each column chunk in this row group. 814 * This list must have the same order as the SchemaElement list in FileMetaData. 815 **/ 816 1: required list<ColumnChunk> columns 817 818 /** Total byte size of all the uncompressed column data in this row group **/ 819 2: required i64 total_byte_size 820 821 /** Number of rows in this row group **/ 822 3: required i64 num_rows 823 824 /** If set, specifies a sort ordering of the rows in this RowGroup. 825 * The sorting columns can be a subset of all the columns. 826 */ 827 4: optional list<SortingColumn> sorting_columns 828 829 /** Byte offset from beginning of file to first page (data or dictionary) 830 * in this row group **/ 831 5: optional i64 file_offset 832 833 /** Total byte size of all compressed (and potentially encrypted) column data 834 * in this row group **/ 835 6: optional i64 total_compressed_size 836 837 /** Row group ordinal in the file **/ 838 7: optional i16 ordinal 839 } 840 841 /** Empty struct to signal the order defined by the physical or logical type */ 842 struct TypeDefinedOrder {} 843 844 /** 845 * Union to specify the order used for the min_value and max_value fields for a 846 * column. This union takes the role of an enhanced enum that allows rich 847 * elements (which will be needed for a collation-based ordering in the future). 848 * 849 * Possible values are: 850 * * TypeDefinedOrder - the column uses the order defined by its logical or 851 * physical type (if there is no logical type). 852 * 853 * If the reader does not support the value of this union, min and max stats 854 * for this column should be ignored. 855 */ 856 union ColumnOrder { 857 858 /** 859 * The sort orders for logical types are: 860 * UTF8 - unsigned byte-wise comparison 861 * INT8 - signed comparison 862 * INT16 - signed comparison 863 * INT32 - signed comparison 864 * INT64 - signed comparison 865 * UINT8 - unsigned comparison 866 * UINT16 - unsigned comparison 867 * UINT32 - unsigned comparison 868 * UINT64 - unsigned comparison 869 * DECIMAL - signed comparison of the represented value 870 * DATE - signed comparison 871 * TIME_MILLIS - signed comparison 872 * TIME_MICROS - signed comparison 873 * TIMESTAMP_MILLIS - signed comparison 874 * TIMESTAMP_MICROS - signed comparison 875 * INTERVAL - unsigned comparison 876 * JSON - unsigned byte-wise comparison 877 * BSON - unsigned byte-wise comparison 878 * ENUM - unsigned byte-wise comparison 879 * LIST - undefined 880 * MAP - undefined 881 * 882 * In the absence of logical types, the sort order is determined by the physical type: 883 * BOOLEAN - false, true 884 * INT32 - signed comparison 885 * INT64 - signed comparison 886 * INT96 (only used for legacy timestamps) - undefined 887 * FLOAT - signed comparison of the represented value (*) 888 * DOUBLE - signed comparison of the represented value (*) 889 * BYTE_ARRAY - unsigned byte-wise comparison 890 * FIXED_LEN_BYTE_ARRAY - unsigned byte-wise comparison 891 * 892 * (*) Because the sorting order is not specified properly for floating 893 * point values (relations vs. total ordering) the following 894 * compatibility rules should be applied when reading statistics: 895 * - If the min is a NaN, it should be ignored. 896 * - If the max is a NaN, it should be ignored. 897 * - If the min is +0, the row group may contain -0 values as well. 898 * - If the max is -0, the row group may contain +0 values as well. 899 * - When looking for NaN values, min and max should be ignored. 900 */ 901 1: TypeDefinedOrder TYPE_ORDER; 902 } 903 904 struct PageLocation { 905 /** Offset of the page in the file **/ 906 1: required i64 offset 907 908 /** 909 * Size of the page, including header. Sum of compressed_page_size and header 910 * length 911 */ 912 2: required i32 compressed_page_size 913 914 /** 915 * Index within the RowGroup of the first row of the page; this means pages 916 * change on record boundaries (r = 0). 917 */ 918 3: required i64 first_row_index 919 } 920 921 struct OffsetIndex { 922 /** 923 * PageLocations, ordered by increasing PageLocation.offset. It is required 924 * that page_locations[i].first_row_index < page_locations[i+1].first_row_index. 925 */ 926 1: required list<PageLocation> page_locations 927 } 928 929 /** 930 * Description for ColumnIndex. 931 * Each <array-field>[i] refers to the page at OffsetIndex.page_locations[i] 932 */ 933 struct ColumnIndex { 934 /** 935 * A list of Boolean values to determine the validity of the corresponding 936 * min and max values. If true, a page contains only null values, and writers 937 * have to set the corresponding entries in min_values and max_values to 938 * byte[0], so that all lists have the same length. If false, the 939 * corresponding entries in min_values and max_values must be valid. 940 */ 941 1: required list<bool> null_pages 942 943 /** 944 * Two lists containing lower and upper bounds for the values of each page. 945 * These may be the actual minimum and maximum values found on a page, but 946 * can also be (more compact) values that do not exist on a page. For 947 * example, instead of storing ""Blart Versenwald III", a writer may set 948 * min_values[i]="B", max_values[i]="C". Such more compact values must still 949 * be valid values within the column's logical type. Readers must make sure 950 * that list entries are populated before using them by inspecting null_pages. 951 */ 952 2: required list<binary> min_values 953 3: required list<binary> max_values 954 955 /** 956 * Stores whether both min_values and max_values are orderd and if so, in 957 * which direction. This allows readers to perform binary searches in both 958 * lists. Readers cannot assume that max_values[i] <= min_values[i+1], even 959 * if the lists are ordered. 960 */ 961 4: required BoundaryOrder boundary_order 962 963 /** A list containing the number of null values for each page **/ 964 5: optional list<i64> null_counts 965 } 966 967 struct AesGcmV1 { 968 /** AAD prefix **/ 969 1: optional binary aad_prefix 970 971 /** Unique file identifier part of AAD suffix **/ 972 2: optional binary aad_file_unique 973 974 /** In files encrypted with AAD prefix without storing it, 975 * readers must supply the prefix **/ 976 3: optional bool supply_aad_prefix 977 } 978 979 struct AesGcmCtrV1 { 980 /** AAD prefix **/ 981 1: optional binary aad_prefix 982 983 /** Unique file identifier part of AAD suffix **/ 984 2: optional binary aad_file_unique 985 986 /** In files encrypted with AAD prefix without storing it, 987 * readers must supply the prefix **/ 988 3: optional bool supply_aad_prefix 989 } 990 991 union EncryptionAlgorithm { 992 1: AesGcmV1 AES_GCM_V1 993 2: AesGcmCtrV1 AES_GCM_CTR_V1 994 } 995 996 /** 997 * Description for file metadata 998 */ 999 struct FileMetaData { 1000 /** Version of this file **/ 1001 1: required i32 version 1002 1003 /** Parquet schema for this file. This schema contains metadata for all the columns. 1004 * The schema is represented as a tree with a single root. The nodes of the tree 1005 * are flattened to a list by doing a depth-first traversal. 1006 * The column metadata contains the path in the schema for that column which can be 1007 * used to map columns to nodes in the schema. 1008 * The first element is the root **/ 1009 2: required list<SchemaElement> schema; 1010 1011 /** Number of rows in this file **/ 1012 3: required i64 num_rows 1013 1014 /** Row groups in this file **/ 1015 4: required list<RowGroup> row_groups 1016 1017 /** Optional key/value metadata **/ 1018 5: optional list<KeyValue> key_value_metadata 1019 1020 /** String for application that wrote this file. This should be in the format 1021 * <Application> version <App Version> (build <App Build Hash>). 1022 * e.g. impala version 1.0 (build 6cf94d29b2b7115df4de2c06e2ab4326d721eb55) 1023 **/ 1024 6: optional string created_by 1025 1026 /** 1027 * Sort order used for the min_value and max_value fields of each column in 1028 * this file. Sort orders are listed in the order matching the columns in the 1029 * schema. The indexes are not necessary the same though, because only leaf 1030 * nodes of the schema are represented in the list of sort orders. 1031 * 1032 * Without column_orders, the meaning of the min_value and max_value fields is 1033 * undefined. To ensure well-defined behaviour, if min_value and max_value are 1034 * written to a Parquet file, column_orders must be written as well. 1035 * 1036 * The obsolete min and max fields are always sorted by signed comparison 1037 * regardless of column_orders. 1038 */ 1039 7: optional list<ColumnOrder> column_orders; 1040 1041 /** 1042 * Encryption algorithm. This field is set only in encrypted files 1043 * with plaintext footer. Files with encrypted footer store algorithm id 1044 * in FileCryptoMetaData structure. 1045 */ 1046 8: optional EncryptionAlgorithm encryption_algorithm 1047 1048 /** 1049 * Retrieval metadata of key used for signing the footer. 1050 * Used only in encrypted files with plaintext footer. 1051 */ 1052 9: optional binary footer_signing_key_metadata 1053 } 1054 1055 /** Crypto metadata for files with encrypted footer **/ 1056 struct FileCryptoMetaData { 1057 /** 1058 * Encryption algorithm. This field is only used for files 1059 * with encrypted footer. Files with plaintext footer store algorithm id 1060 * inside footer (FileMetaData structure). 1061 */ 1062 1: required EncryptionAlgorithm encryption_algorithm 1063 1064 /** Retrieval metadata of key used for encryption of footer, 1065 * and (possibly) columns **/ 1066 2: optional binary key_metadata 1067 } 1068