> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-fbfa8bee.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> ParquetMetadata 格式文档

# ParquetMetadata

<div id="description">
  ## 描述
</div>

用于读取 Parquet 文件元数据的特殊格式 ([https://parquet.apache.org/docs/file-format/metadata/)。它始终只输出一行，结构/内容如下：](https://parquet.apache.org/docs/file-format/metadata/\)。它始终只输出一行，结构/内容如下：)

* `num_columns` - 列数
* \`\`num\_rows\` - 总行数
* `num_row_groups` - 行组总数
* `format_version` - Parquet 格式版本，始终为 1.0 或 2.6
* `total_uncompressed_size` - 数据未压缩的总字节大小，计算方式为所有行组的 total\_byte\_size 之和
* `total_compressed_size` - 数据压缩后的总字节大小，计算方式为所有行组的 total\_compressed\_size 之和
* `columns` - 列元数据列表，结构如下：
  * `name` - 列名
  * `path` - 列路径 (对于嵌套列，与 name 不同)
  * `max_definition_level` - 最大定义级别
  * `max_repetition_level` - 最大重复级别
  * `physical_type` - 列的物理类型
  * `logical_type` - 列的逻辑类型
  * `compression` - 此列使用的压缩方式
  * `total_uncompressed_size` - 该列未压缩的总字节大小，计算方式为所有行组中该列的 total\_uncompressed\_size 之和
  * `total_compressed_size` - 该列压缩后的总字节大小，计算方式为所有行组中该列的 total\_compressed\_size 之和
  * `space_saved` - 压缩节省的空间百分比，计算方式为 (1 - total\_compressed\_size/total\_uncompressed\_size)。
  * `encodings` - 此列使用的编码列表
* `row_groups` - 行组元数据列表，结构如下：
  * `num_columns` - 行组中的列数
  * `num_rows` - 行组中的行数
  * `total_uncompressed_size` - 行组未压缩的总字节大小
  * `total_compressed_size` - 行组压缩后的总字节大小
  * `columns` - 列块元数据列表，结构如下：
    * `name` - 列名
    * `path` - 列路径
    * `total_compressed_size` - 该列压缩后的总字节大小
    * `total_uncompressed_size` - 行组未压缩的总字节大小
    * `have_statistics` - 布尔标志，表示列块元数据是否包含列统计信息
    * `statistics` - 列块统计信息 (如果 have\_statistics = false，则所有字段均为 NULL) ，结构如下：
      * `num_values` - 列块中非 NULL 值的数量
      * `null_count` - 列块中 NULL 值的数量
      * `distinct_count` - 列块中不同值的数量
      * `min` - 列块的最小值
      * `max` - 列块的最大值

<div id="example-usage">
  ## 示例用法
</div>

示例：

```sql theme={null}
SELECT * 
FROM file(data.parquet, ParquetMetadata) 
FORMAT PrettyJSONEachRow
```

```json theme={null}
{
    "num_columns": "2",
    "num_rows": "100000",
    "num_row_groups": "2",
    "format_version": "2.6",
    "metadata_size": "577",
    "total_uncompressed_size": "282436",
    "total_compressed_size": "26633",
    "columns": [
        {
            "name": "number",
            "path": "number",
            "max_definition_level": "0",
            "max_repetition_level": "0",
            "physical_type": "INT32",
            "logical_type": "Int(bitWidth=16, isSigned=false)",
            "compression": "LZ4",
            "total_uncompressed_size": "133321",
            "total_compressed_size": "13293",
            "space_saved": "90.03%",
            "encodings": [
                "RLE_DICTIONARY",
                "PLAIN",
                "RLE"
            ]
        },
        {
            "name": "concat('Hello', toString(modulo(number, 1000)))",
            "path": "concat('Hello', toString(modulo(number, 1000)))",
            "max_definition_level": "0",
            "max_repetition_level": "0",
            "physical_type": "BYTE_ARRAY",
            "logical_type": "None",
            "compression": "LZ4",
            "total_uncompressed_size": "149115",
            "total_compressed_size": "13340",
            "space_saved": "91.05%",
            "encodings": [
                "RLE_DICTIONARY",
                "PLAIN",
                "RLE"
            ]
        }
    ],
    "row_groups": [
        {
            "num_columns": "2",
            "num_rows": "65409",
            "total_uncompressed_size": "179809",
            "total_compressed_size": "14163",
            "columns": [
                {
                    "name": "number",
                    "path": "number",
                    "total_compressed_size": "7070",
                    "total_uncompressed_size": "85956",
                    "have_statistics": true,
                    "statistics": {
                        "num_values": "65409",
                        "null_count": "0",
                        "distinct_count": null,
                        "min": "0",
                        "max": "999"
                    }
                },
                {
                    "name": "concat('Hello', toString(modulo(number, 1000)))",
                    "path": "concat('Hello', toString(modulo(number, 1000)))",
                    "total_compressed_size": "7093",
                    "total_uncompressed_size": "93853",
                    "have_statistics": true,
                    "statistics": {
                        "num_values": "65409",
                        "null_count": "0",
                        "distinct_count": null,
                        "min": "Hello0",
                        "max": "Hello999"
                    }
                }
            ]
        },
        ...
    ]
}
```
