code: def test_parquet_metadata_api():
      df = alltypes_sample(size=10000)
      df = df.reindex(columns=sorted(df.columns))
      df.index = np.random.randint(0, 1000000, size=len(df))
  
      fileh = make_sample_file(df)
      ncols = len(df.columns)
  
      # Series of sniff tests
      meta = fileh.metadata
      repr(meta)
      assert meta.num_rows == len(df)
      assert meta.num_columns == ncols + 1  # +1 for index
      assert meta.num_row_groups == 1
      assert meta.format_version == "2.6"
      assert "parquet-cpp" in meta.created_by
      assert isinstance(meta.serialized_size, int)
      assert isinstance(meta.metadata, dict)
  
      # Schema
      schema = fileh.schema
      assert meta.schema is schema
      assert len(schema) == ncols + 1  # +1 for index
      repr(schema)
  
      col = schema[0]
      repr(col)
      assert col.name == df.columns[0]
      assert col.max_definition_level == 1
      assert col.max_repetition_level == 0
      assert col.max_repetition_level == 0
  
      assert col.physical_type == "BOOLEAN"
      assert col.converted_type == "NONE"
  
      with pytest.raises(IndexError):
          schema[ncols + 1]  # +1 for index
  
      with pytest.raises(IndexError):
          schema[-1]
  
      # Row group
      for rg in range(meta.num_row_groups):
          rg_meta = meta.row_group(rg)
          assert isinstance(rg_meta, pq.RowGroupMetaData)
          repr(rg_meta)
  
          for col in range(rg_meta.num_columns):
              col_meta = rg_meta.column(col)
              assert isinstance(col_meta, pq.ColumnChunkMetaData)
              repr(col_meta)
  
      with pytest.raises(IndexError):
          meta.row_group(-1)
  
      with pytest.raises(IndexError):
          meta.row_group(meta.num_row_groups + 1)
  
      rg_meta = meta.row_group(0)
      assert rg_meta.num_rows == len(df)
      assert rg_meta.num_columns == ncols + 1  # +1 for index
      assert rg_meta.total_byte_size > 0
  
      with pytest.raises(IndexError):
          col_meta = rg_meta.column(-1)
  
      with pytest.raises(IndexError):
          col_meta = rg_meta.column(ncols + 2)
  
      col_meta = rg_meta.column(0)
      assert col_meta.file_offset > 0
      assert col_meta.file_path == ""  # created from BytesIO
      assert col_meta.physical_type == "BOOLEAN"
      assert col_meta.num_values == 10000
      assert col_meta.path_in_schema == "bool"
      assert col_meta.is_stats_set is True
      assert isinstance(col_meta.statistics, pq.Statistics)
      assert col_meta.compression == "SNAPPY"
      assert set(col_meta.encodings) == {"PLAIN", "RLE"}
      assert col_meta.has_dictionary_page is False
      assert col_meta.dictionary_page_offset is None
      assert col_meta.data_page_offset > 0
      assert col_meta.total_compressed_size > 0
      assert col_meta.total_uncompressed_size > 0
      with pytest.raises(NotImplementedError):
          col_meta.has_index_page
      with pytest.raises(NotImplementedError):
          col_meta.index_page_offset
  
imports: import datetime
  import decimal
  from collections import OrderedDict
  import io
  import numpy
  import pytest
  import pyarrow
  from pyarrow.tests.parquet.common import _check_roundtrip, make_sample_file
  from pyarrow.fs import LocalFileSystem
  from pyarrow.tests import util
label_desc: Use image node_id 1 for calling a global function with example usage: test_parquet_metadata_api() without return types