Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2611

Provide warnings for mismatched logical/literal schema

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.10.0
    • python
    • None

    Description

      The spec says

      Language implementations must ignore unknown logical types when reading, and should use the underlying Avro type. If a logical type is invalid, for example a decimal with scale greater than its precision, then implementations should ignore the logical type and use the underlying Avro type.

      Work to adhere to this is in AVRO-2429. However, users debugging their avro usage may wish to get more feedback about logical and literal schema mismatches. So I propose that we use the Python warnings module to provide warnings about schema mismatches, which will natively give the user control over what warnings they see. Here's an excerpt from the Python warnings documentation:

      Warning messages are normally written to sys.stderr, but their disposition can be changed flexibly, from ignoring all warnings to turning them into exceptions. The disposition of warnings can vary based on the warning category (see below), the text of the warning message, and the source location where it is issued. Repetitions of a particular warning for the same source location are typically suppressed.

      The logging module also supports easily transforming warnings into logger.warn calls.

      We should create a subclass of UserWarning from which all future avro warnings should extend, and then create an IgnoredLogicalType warning from that for this case.

      I think the warning should be enabled in "once" mode by default.

      Attachments

        Issue Links

          Activity

            People

              rskraba Ryan Skraba
              kojiromike Michael A. Smith
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: