[jira] [Commented] (FLINK-35112) Membership for Row class does not include field names
[ https://issues.apache.org/jira/browse/FLINK-35112?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17837965#comment-17837965 ] Dian Fu commented on FLINK-35112: - Great (y). Thanks [~wzorgdrager] > Membership for Row class does not include field names > - > > Key: FLINK-35112 > URL: https://issues.apache.org/jira/browse/FLINK-35112 > Project: Flink > Issue Type: Bug > Components: API / Python >Affects Versions: 1.18.1 >Reporter: Wouter Zorgdrager >Priority: Minor > > 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) > # Expected to be True, but is False > print("name" in row) > person = Row("name", "age") > # 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 > ``` -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (FLINK-35112) Membership for Row class does not include field names
[ https://issues.apache.org/jira/browse/FLINK-35112?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17837538#comment-17837538 ] Wouter Zorgdrager commented on FLINK-35112: --- [~dianfu] sure, I can submit a PR for this! > Membership for Row class does not include field names > - > > Key: FLINK-35112 > URL: https://issues.apache.org/jira/browse/FLINK-35112 > Project: Flink > Issue Type: Bug > Components: API / Python >Affects Versions: 1.18.1 >Reporter: Wouter Zorgdrager >Priority: Minor > > 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) > # Expected to be True, but is False > print("name" in row) > person = Row("name", "age") > # 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 > ``` -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (FLINK-35112) Membership for Row class does not include field names
[ https://issues.apache.org/jira/browse/FLINK-35112?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17837512#comment-17837512 ] Dian Fu commented on FLINK-35112: - Sounds reasonable for me. [~wzorgdrager] Do you want to submit a PR for this issue? > Membership for Row class does not include field names > - > > Key: FLINK-35112 > URL: https://issues.apache.org/jira/browse/FLINK-35112 > Project: Flink > Issue Type: Bug > Components: API / Python >Affects Versions: 1.18.1 >Reporter: Wouter Zorgdrager >Priority: Minor > > 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) > # Expected to be True, but is False > print("name" in row) > person = Row("name", "age") > # 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 > ``` -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (FLINK-35112) Membership for Row class does not include field names
[ https://issues.apache.org/jira/browse/FLINK-35112?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17837257#comment-17837257 ] Martijn Visser commented on FLINK-35112: [~dianfu] [~hxbks2ks] WDYT? > Membership for Row class does not include field names > - > > Key: FLINK-35112 > URL: https://issues.apache.org/jira/browse/FLINK-35112 > Project: Flink > Issue Type: Bug > Components: API / Python >Affects Versions: 1.18.1 >Reporter: Wouter Zorgdrager >Priority: Minor > > 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) > # Expected to be True, but is False > print("name" in row) > person = Row("name", "age") > # 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 > ``` -- This message was sent by Atlassian Jira (v8.20.10#820010)