rdblue commented on code in PR #4920: URL: https://github.com/apache/iceberg/pull/4920#discussion_r895216218
########## python/src/iceberg/avro/codec.py: ########## @@ -0,0 +1,196 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + +""" +Contains Codecs for Python Avro. + +Note that the word "codecs" means "compression/decompression algorithms" in the +Avro world (https://avro.apache.org/docs/current/spec.html#Object+Container+Files), +so don't confuse it with the Python's "codecs", which is a package mainly for +converting character sets (https://docs.python.org/3/library/codecs.html). +""" + +import binascii +import io +import logging +import struct +import zlib +from abc import ABC, abstractmethod +from typing import Dict, Tuple, Type + +from iceberg.avro.decoder import BinaryDecoder +from iceberg.io.memory import MemoryInputStream + +logger = logging.getLogger(__name__) + +STRUCT_CRC32 = struct.Struct(">I") # big-endian unsigned int + +has_bzip2 = False +try: + import bz2 + + has_bzip2 = True +except ImportError: + logger.info("bzip2 compression not available, install python with bz2 headers available") +except Exception as e: + logger.exception(f"snappy compression not available; {e}") + +has_snappy = False +try: + import snappy + + has_snappy = True +except ImportError: + logger.info("snappy compression not available, please install with python-snappy") +except Exception as e: + logger.exception(f"snappy compression not available; {e}") + +has_zstandard = False +try: + import zstandard as zstd + + has_zstandard = True +except ImportError: + logger.info("zstandard compression not available, please install with zstandard") Review Comment: Shouldn't we only log this if the user tries to read a file with Zstd compression and it isn't installed? I always find it annoying when code tells me that optional things aren't available because I have chosen not to install them. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
