Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] KeyError in MapScalar with custom field name #36809

Closed
0x26res opened this issue Jul 21, 2023 · 0 comments · Fixed by #36830
Closed

[Python] KeyError in MapScalar with custom field name #36809

0x26res opened this issue Jul 21, 2023 · 0 comments · Fixed by #36830

Comments

@0x26res
Copy link
Contributor

0x26res commented Jul 21, 2023

Describe the bug, including details regarding any error messages, version, and platform.

It is possible to customize the name of the value field for pa.MapType. I believe it's a niche feature used for compatibility with parquet and it doesn't change the semantic of the map type.

this feature causes a KeyError in MapScalar.as_py:

def test_bug_in_pyarrow():
    assert pa.scalar(
        [("foo", "bar")],
        pa.map_(
            pa.string(),
            pa.field("value", pa.string()),
        ),
    ).as_py() == [("foo", "bar")]

    with pytest.raises(KeyError, match=r"value"):
        pa.scalar(
            [("foo", "bar")],
            pa.map_(
                pa.string(),
                pa.field("map_value", pa.string()),
            ),
        ).as_py()

Component(s)

Python

@kou kou changed the title KeyError in MapScalar with custom field name [Python] KeyError in MapScalar with custom field name Jul 24, 2023
0x26res pushed a commit to 0x26res/arrow that referenced this issue Jul 24, 2023
0x26res pushed a commit to 0x26res/arrow that referenced this issue Jul 25, 2023
kou pushed a commit that referenced this issue Jul 26, 2023
### Rationale for this change

`MapScalar.as_py` doesn't take into account custom key/value field names

### What changes are included in this PR?

Fix and tests 

### Are these changes tested?

Simple unit test

### Are there any user-facing changes?

No API changes.
* Closes: #36809

Authored-by: aandres <aandres@tradewelltech.co>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
@kou kou added this to the 14.0.0 milestone Jul 26, 2023
R-JunmingChen pushed a commit to R-JunmingChen/arrow that referenced this issue Aug 20, 2023
…he#36830)

### Rationale for this change

`MapScalar.as_py` doesn't take into account custom key/value field names

### What changes are included in this PR?

Fix and tests 

### Are these changes tested?

Simple unit test

### Are there any user-facing changes?

No API changes.
* Closes: apache#36809

Authored-by: aandres <aandres@tradewelltech.co>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
loicalleyne pushed a commit to loicalleyne/arrow that referenced this issue Nov 13, 2023
…he#36830)

### Rationale for this change

`MapScalar.as_py` doesn't take into account custom key/value field names

### What changes are included in this PR?

Fix and tests 

### Are these changes tested?

Simple unit test

### Are there any user-facing changes?

No API changes.
* Closes: apache#36809

Authored-by: aandres <aandres@tradewelltech.co>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants