code: def test_column_encoding():
      arr_float = pa.array(list(map(float, range(100))))
      arr_int = pa.array(list(map(int, range(100))))
      arr_bin = pa.array([str(x) for x in range(100)], type=pa.binary())
      arr_flba = pa.array(
          [str(x).zfill(10) for x in range(100)], type=pa.binary(10)
      )
      arr_bool = pa.array([False, True, False, False] * 25)
      mixed_table = pa.Table.from_arrays(
          [arr_float, arr_int, arr_bin, arr_flba, arr_bool],
          names=["a", "b", "c", "d", "e"],
      )
  
      # Check "BYTE_STREAM_SPLIT" for column 'a' and "PLAIN" column_encoding for
      # column 'b' and 'c'.
      _check_roundtrip(
          mixed_table,
          expected=mixed_table,
          use_dictionary=False,
          column_encoding={
              "a": "BYTE_STREAM_SPLIT",
              "b": "PLAIN",
              "c": "PLAIN",
          },
      )
  
      # Check "PLAIN" for all columns.
      _check_roundtrip(
          mixed_table,
          expected=mixed_table,
          use_dictionary=False,
          column_encoding="PLAIN",
      )
  
      # Check "DELTA_BINARY_PACKED" for integer columns.
      _check_roundtrip(
          mixed_table,
          expected=mixed_table,
          use_dictionary=False,
          column_encoding={
              "a": "PLAIN",
              "b": "DELTA_BINARY_PACKED",
              "c": "PLAIN",
          },
      )
  
      # Check "DELTA_LENGTH_BYTE_ARRAY" for byte columns.
      _check_roundtrip(
          mixed_table,
          expected=mixed_table,
          use_dictionary=False,
          column_encoding={
              "a": "PLAIN",
              "b": "DELTA_BINARY_PACKED",
              "c": "DELTA_LENGTH_BYTE_ARRAY",
          },
      )
  
      # Check "DELTA_BYTE_ARRAY" for byte columns.
      _check_roundtrip(
          mixed_table,
          expected=mixed_table,
          use_dictionary=False,
          column_encoding={
              "a": "PLAIN",
              "b": "DELTA_BINARY_PACKED",
              "c": "DELTA_BYTE_ARRAY",
              "d": "DELTA_BYTE_ARRAY",
          },
      )
  
      # Check "RLE" for boolean columns.
      _check_roundtrip(
          mixed_table,
          expected=mixed_table,
          use_dictionary=False,
          column_encoding={"e": "RLE"},
      )
  
      # Try to pass "BYTE_STREAM_SPLIT" column encoding for integer column 'b'.
      # This should throw an error as it is only supports FLOAT and DOUBLE.
      with pytest.raises(
          IOError,
          match="BYTE_STREAM_SPLIT only supports FLOAT and" " DOUBLE",
      ):
          _check_roundtrip(
              mixed_table,
              expected=mixed_table,
              use_dictionary=False,
              column_encoding={
                  "a": "PLAIN",
                  "b": "BYTE_STREAM_SPLIT",
                  "c": "PLAIN",
              },
          )
  
      # Try to pass use "DELTA_BINARY_PACKED" encoding on float column.
      # This should throw an error as only integers are supported.
      with pytest.raises(OSError):
          _check_roundtrip(
              mixed_table,
              expected=mixed_table,
              use_dictionary=False,
              column_encoding={
                  "a": "DELTA_BINARY_PACKED",
                  "b": "PLAIN",
                  "c": "PLAIN",
              },
          )
  
      # Try to pass "RLE_DICTIONARY".
      # This should throw an error as dictionary encoding is already used by
      # default and not supported to be specified as "fallback" encoding
      with pytest.raises(ValueError):
          _check_roundtrip(
              mixed_table,
              expected=mixed_table,
              use_dictionary=False,
              column_encoding="RLE_DICTIONARY",
          )
  
      # Try to pass unsupported encoding.
      with pytest.raises(ValueError):
          _check_roundtrip(
              mixed_table,
              expected=mixed_table,
              use_dictionary=False,
              column_encoding={"a": "MADE_UP_ENCODING"},
          )
  
      # Try to pass column_encoding and use_dictionary.
      # This should throw an error.
      with pytest.raises(ValueError):
          _check_roundtrip(
              mixed_table,
              expected=mixed_table,
              use_dictionary=["b"],
              column_encoding={"b": "PLAIN"},
          )
  
      # Try to pass column_encoding and use_dictionary=True (default value).
      # This should throw an error.
      with pytest.raises(ValueError):
          _check_roundtrip(
              mixed_table,
              expected=mixed_table,
              column_encoding={"b": "PLAIN"},
          )
  
      # Try to pass column_encoding and use_byte_stream_split on same column.
      # This should throw an error.
      with pytest.raises(ValueError):
          _check_roundtrip(
              mixed_table,
              expected=mixed_table,
              use_dictionary=False,
              use_byte_stream_split=["a"],
              column_encoding={
                  "a": "RLE",
                  "b": "BYTE_STREAM_SPLIT",
                  "c": "PLAIN",
              },
          )
  
      # Try to pass column_encoding and use_byte_stream_split=True.
      # This should throw an error.
      with pytest.raises(ValueError):
          _check_roundtrip(
              mixed_table,
              expected=mixed_table,
              use_dictionary=False,
              use_byte_stream_split=True,
              column_encoding={
                  "a": "RLE",
                  "b": "BYTE_STREAM_SPLIT",
                  "c": "PLAIN",
              },
          )
  
      # Try to pass column_encoding=True.
      # This should throw an error.
      with pytest.raises(TypeError):
          _check_roundtrip(
              mixed_table,
              expected=mixed_table,
              use_dictionary=False,
              column_encoding=True,
          )
  
imports: from collections import OrderedDict
  import io
  import warnings
  from shutil import copytree
  import numpy
  import pytest
  import pyarrow
  from pyarrow import fs
  from pyarrow.filesystem import LocalFileSystem, FileSystem
  from pyarrow.tests import util
  from pyarrow.tests.parquet.common import _check_roundtrip, _roundtrip_table, _test_dataframe
label_desc: Use image node_id 21 for calling a global function with example usage: test_column_encoding() without return types