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

feat(python, rust): add statistics_enabled to ColumnProperties #3126

Merged
merged 4 commits into from
Jan 15, 2025

Conversation

maxitg
Copy link
Contributor

@maxitg maxitg commented Jan 14, 2025

Description

  • Add support for statistics_enabled in ColumnProperties.
  • Remove deprecated and unused max_statistics_size from ColumnProperties.

Related Issue(s)

Documentation

The only available way currently to avoid writing statistics to the transaction log for a column is via max_statistics_size. However, that has been deprecated in arrow-rs, furthermore it appears to be ignored: apache/arrow-rs#2033. Being able to skip statistics is necessary for large data columns, as otherwise transaction log explodes after a few tens of thousands of transactions and becomes non-scalable.

Examples

from deltalake import DeltaTable, write_deltalake, WriterProperties, ColumnProperties
import pandas as pd
import pyarrow as pa
from pathlib import Path
import shutil

data = {'int': [0, 1, 2], 'data': [b'0' * 100000, b'1' * 100000, b'2' * 100000]}

df = pd.DataFrame(data)

def check_size(data_column_properties: ColumnProperties):
    TMP_PATH = "/tmp/delta-test/delta-test-0"

    shutil.rmtree(TMP_PATH, ignore_errors=True)
    write_deltalake(
        TMP_PATH,
        df.sort_values(["int"]),
        schema=pa.schema([pa.field("int", pa.int64()), pa.field("data", pa.binary())]),
        mode="append",
        writer_properties=WriterProperties(
            compression="zstd",
            column_properties={"data": data_column_properties},
        ),
        engine="rust",
    )

    print(DeltaTable(TMP_PATH).to_pandas())

    return (Path(TMP_PATH) / "_delta_log/00000000000000000000.json").stat().st_size

[check_size(c)
 for c
 in [ColumnProperties(max_statistics_size=0), ColumnProperties(statistics_enabled="NONE")]]

#    int                                               data
# 0    0  b'00000000000000000000000000000000000000000000...
# 1    1  b'11111111111111111111111111111111111111111111...
# 2    2  b'22222222222222222222222222222222222222222222...
#    int                                               data
# 0    0  b'00000000000000000000000000000000000000000000...
# 1    1  b'11111111111111111111111111111111111111111111...
# 2    2  b'22222222222222222222222222222222222222222222...
# [201143, 1100]

@github-actions github-actions bot added the binding/python Issues for the Python package label Jan 14, 2025
Signed-off-by: Max Piskunov <max.piskunov@plus.ai>
@maxitg maxitg force-pushed the column-properties-statistics-enabled branch from 775dff4 to c934459 Compare January 14, 2025 01:10
Copy link

codecov bot commented Jan 14, 2025

Codecov Report

Attention: Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.

Project coverage is 72.24%. Comparing base (ef066c4) to head (c934459).

Files with missing lines Patch % Lines
python/src/lib.rs 0.00% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3126      +/-   ##
==========================================
- Coverage   72.28%   72.24%   -0.04%     
==========================================
  Files         134      134              
  Lines       42973    42988      +15     
  Branches    42973    42988      +15     
==========================================
- Hits        31062    31056       -6     
- Misses       9923     9940      +17     
- Partials     1988     1992       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ion-elgreco
Copy link
Collaborator

@maxitg looks good, could you remove the max_statistics_size as well?

@maxitg
Copy link
Contributor Author

maxitg commented Jan 14, 2025

@maxitg looks good, could you remove the max_statistics_size as well?

@ion-elgreco I’ve added a second commit to remove it. I initially avoided it to prevent a breaking change.

Signed-off-by: Max Piskunov <max.piskunov@plus.ai>
@maxitg maxitg force-pushed the column-properties-statistics-enabled branch from ca754fc to 92f5cac Compare January 14, 2025 17:18
@rtyler rtyler added this to the v0.24 milestone Jan 15, 2025
Copy link
Member

@rtyler rtyler left a comment

Choose a reason for hiding this comment

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

Thanks for the improvement! This is a situation where I'm definitely okay with breaking changes since the code wasn't working anyways, we're also on the precipice of a breaking set of changes anyways 😄

@rtyler rtyler enabled auto-merge January 15, 2025 02:53
@rtyler rtyler added this pull request to the merge queue Jan 15, 2025
auto-merge was automatically disabled January 15, 2025 03:56

Pull Request is not mergeable

Merged via the queue into delta-io:main with commit d73a9af Jan 15, 2025
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binding/python Issues for the Python package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants