Spark, Parquet 파일 작업 중, Parquet 파일 내부의 meta data를 조회를 리뷰할 필요가 있어서 진행.

생각보다 많은 정보를 parquet의 meta 데이터에서 추출할 수 있었다. 

 

parquet 파일의 meta 정보 추출

 

관련 코드는 아래에서 전체 내용을 참조 가능.

pyspark-basic/parquet-metadata.ipynb at main · CloudBreadPaPa/pyspark-basic (github.com)

 

로드한 Parquet 파일에서 meta 정보 출력

parquet_file.metadata

결과

<pyarrow._parquet.FileMetaData object at 0x7f7e40589310>
  created_by: parquet-cpp-arrow version 4.0.1
  num_columns: 83
  num_rows: 9999
  num_row_groups: 1
  format_version: 1.0
  serialized_size: 19443

 

parquet_file.schema

결과

<pyarrow._parquet.ParquetSchema object at 0x7f7e404b73c0>
required group field_id=-1 schema {
  optional binary field_id=-1 MachineIdentifier (String);
  optional binary field_id=-1 ProductName (String);
  optional binary field_id=-1 EngineVersion (String);
  optional binary field_id=-1 AppVersion (String);
  optional binary field_id=-1 AvSigVersion (String);

...

 

parquet_file.metadata.row_group(0).column(3)

결과

<pyarrow._parquet.ColumnChunkMetaData object at 0x7f7e600f3b30>
  file_offset: 324387
  file_path: 
  physical_type: BYTE_ARRAY
  num_values: 9999
  path_in_schema: AppVersion
  is_stats_set: True
  statistics:
    <pyarrow._parquet.Statistics object at 0x7f7e600f3590>
      has_min_max: True
      min: 4.10.14393.0
      max: 4.9.218.0
      null_count: 0
      distinct_count: 0
      num_values: 9999
      physical_type: BYTE_ARRAY
      logical_type: String
      converted_type (legacy): UTF8
  compression: SNAPPY
  encodings: ('PLAIN_DICTIONARY', 'PLAIN', 'RLE')
  has_dictionary_page: True
  dictionary_page_offset: 317350
  data_page_offset: 317874
  total_compressed_size: 7037
  total_uncompressed_size: 8512

 

parquet_file.metadata.row_group(0).column(3).statistics

결과

<pyarrow._parquet.Statistics object at 0x7f7e600f3810>
  has_min_max: True
  min: 4.10.14393.0
  max: 4.9.218.0
  null_count: 0
  distinct_count: 0
  num_values: 9999
  physical_type: BYTE_ARRAY
  logical_type: String
  converted_type (legacy): UTF8

 

# check memory mapping
pq_array = pa.parquet.read_table(file_path, memory_map=True)
print("RSS: {}MB".format(pa.total_allocated_bytes() >> 20))

결과

RSS: 24MB

 

 

참고자료

pyspark-basic/parquet-metadata.ipynb at main · CloudBreadPaPa/pyspark-basic (github.com)

Reading and Writing the Apache Parquet Format — Apache Arrow v6.0.0

How to use pyarrow to view the metadata information inside a Parquet file | Open Knowledge Base (openkb.info)

No. Subject Author Date Views
Notice SQL강좌: 챗GPT와 함께 배우는 SQL Server 무료 강좌 목차와 소개 (2023년 9월 업데이트) 코난(김대우) 2023.08.18 38421
Notice Python 무료 강좌 - 기초, 중급, 머신러닝(2023년 6월 업데이트) 코난(김대우) 2021.01.01 20740
118 오픈소스 소통을 위한 Git 공부하기 | ep6. 내 저장소에 소스를 푸시하기 위한 Fork | 애저 듣고보는 잡학지식 코난(김대우) 2022.11.02 94
117 오픈소스 소통을 위한 Git 공부하기 | ep5. 브랜치 (Branch) 이해하기 | 애저 듣고보는 잡학지식 코난(김대우) 2022.11.01 55
116 오픈소스 소통을 위한 Git 공부하기 | ep4. 변경 단위를 만들기 위한 Commit | 애저 듣고보는 잡학지식 코난(김대우) 2022.10.31 90
115 오픈소스 소통을 위한 Git 공부하기 | ep3. 소스를 가져오기 위한 Clone | 애저 듣고보는 잡학지식 코난(김대우) 2022.10.30 80
114 오픈소스 소통을 위한 Git 공부하기 | ep2. Git를 소개합니다 | 애저 듣고보는 잡학지식 코난(김대우) 2022.10.28 91
113 오픈소스 소통을 위한 Git 공부하기 | ep1. 버전 관리의 중요성 | 애저 듣고보는 잡학지식 코난(김대우) 2022.10.27 91
112 오픈소스 소통을 위한 Git 공부하기 | ep0. 인트로 | 애저 듣고보는 잡학지식 코난(김대우) 2022.10.24 140
111 Azure VM - 오픈소스 ROS Gazebo Web 설치 및 실행 file 코난(김대우) 2022.10.19 194
» parquet 파일의 meta 정보 추출 코난(김대우) 2021.11.16 1180
109 embedded SQL - GlueSQL, rust 기반 오픈소스 프로젝트 file 코난(김대우) 2021.10.22 463
108 대규모 머신러닝 프로젝트 Serving에 사용되는 Python WAS, ASGI - uvicorn file 코난(김대우) 2021.10.06 1039
107 Apache Arrow 리뷰 file 코난(김대우) 2021.10.05 2063
106 autopep8을 이용한 python 린트(linting) 구현 코난(김대우) 2021.09.15 704
105 Python에서 환경변수(environment variable) 처리 코난(김대우) 2021.09.15 277
104 Python에서 random 문자열이나 숫자 가져오는 방법 코난(김대우) 2021.09.15 995
103 Python 중급 강좌 - 9. 비동기 작업(Asynchronous operations): asyncio 코난(김대우) 2021.01.03 802
102 Python 중급 강좌 - 8. 외부 리소스 관리(Managing external resources): with 코난(김대우) 2021.01.03 465
101 Python 중급 강좌 - 7. 파일작업(File read/write) file 코난(김대우) 2021.01.03 1477
100 Python 중급 강좌 - 6. 파일시스템(File system) 관리 코난(김대우) 2021.01.03 771
99 Python 중급 강좌 - 5. 다중상속(Mixins - multiple inheritance) 코난(김대우) 2021.01.03 544





XE Login