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

Membership for Row class does not include field names

    XMLWordPrintableJSON

Details

    Description

      In the Row class in PyFlink I cannot do a membership check for field names. This minimal example will show the unexpected behavior:

      ```

      from pyflink.common import Row

      row = Row(name="Alice", age=11)

      1. Expected to be True, but is False
        print("name" in row)

      person = Row("name", "age")

      1. This is True, as expected
        print('name' in person)

      ```

      The related code in the Row class is:
      ```
          def _contains_(self, item):
              return item in self._values
      ```

      It should be relatively easy to fix with the following code:
      ```
          def _contains_(self, item):
              if hasattr(self, "_fields"):
                  return item in self._fields
              else:
                  return item in self._values
      ```

      Attachments

        Issue Links

          Activity

            People

              wzorgdrager Wouter Zorgdrager
              wzorgdrager Wouter Zorgdrager
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: