Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-6024

Need more fine-grained info for "InvalidProgramException: This type (...) cannot be used as key"

    XMLWordPrintableJSON

Details

    Description

      I got this very confusing exception:

      InvalidProgramException: This type (MyType) cannot be used as key
      

      I dug through the code, and could not find what was causing this. The help text for type.isKeyType(), in Keys.java:329, right before the exception is thrown, says: "Checks whether this type can be used as a key. As a bare minimum, types have to be hashable and comparable to be keys." However, this didn't solve the problem.

      I discovered that in my case, the error was occurring because I added a new constructor to the type, and I didn't have a default constructor. This is probably quite a common thing to happen for POJOs, so the error message should give some detail saying that this is the problem.

      Other things that can cause this to fail, including that the class is not public, or the constructor is not public, or the key field is not public, or that the key field is not a serializable type, or the key is not Comparable, or the key is not hashable, should be given in the error message instead, depending on the actual cause of the problem.

      Attachments

        Activity

          People

            Unassigned Unassigned
            lukehutch Luke Hutchison
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: