Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@Fokko
Copy link
Contributor

@Fokko Fokko commented Oct 29, 2024

Fixes #1255

Copy link
Contributor

@kevinjqliu kevinjqliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

return pa.StructArray.from_arrays(
arrays=field_arrays,
fields=pa.struct(fields),
mask=struct_array.is_null() if isinstance(struct_array, pa.StructArray) else None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pyarrow_table: pa.Table = pa.Table.from_pylist(records, schema=schema)
table.append(pyarrow_table)

assert pyarrow_table.to_pandas()["struct_field_1"].tolist() == table.scan().to_pandas()["struct_field_1"].tolist()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the null masking is also done by pandas.

>>> pyarrow_table['struct_field_1']
<pyarrow.lib.ChunkedArray object at 0x10482c6d0>
[
  -- is_valid:
      [
      false
    ]
  -- child 0 type: string
    [
      ""
    ]
  -- child 1 type: int32
    [
      0
    ]
  -- child 2 type: float
    [
      0
    ]
]
>>> pyarrow_table['struct_field_1'].to_pandas()
0    None
Name: struct_field_1, dtype: object

@Fokko Fokko merged commit 9a6a9a1 into apache:main Oct 29, 2024
@Fokko Fokko deleted the fd-null branch October 29, 2024 21:19
@Fokko
Copy link
Contributor Author

Fokko commented Oct 29, 2024

Thanks for the prompt review @kevinjqliu

sungwy pushed a commit to sungwy/iceberg-python that referenced this pull request Dec 7, 2024
* PyArrow: Pass in null-mask

* Add missing flag
sungwy pushed a commit to sungwy/iceberg-python that referenced this pull request Dec 7, 2024
* PyArrow: Pass in null-mask

* Add missing flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Why is the struct field not null when the data is empty?

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.