delta-io / delta-rs

A native Rust library for Delta Lake, with bindings into Python
https://delta-io.github.io/delta-rs/
Apache License 2.0
2.21k stars 394 forks source link

Possibly refactor import statements in Python documentation #634

Closed MrPowers closed 1 month ago

MrPowers commented 2 years ago

The documentation currently uses import statements like this:

from deltalake import DeltaTable
from deltalake import DataCatalog

I usually see Python import statements like this:

import pandas as pd
import numpy as np
import dask.dataframe as dd

Should we refactor the docs to use this import syntax:

import deltalake as dl

If we follow this import syntax we'll have to do dl.DeltaTable("../rust/tests/data/delta-0.2.0") and dl.DataCatalog.AWS, but I actually think this namespacing is nice. Let me know if you're alright with this suggestion and I'll be happy to submit a pull request to update the docs, thanks!

wjones127 commented 2 years ago

I'm not opposed to that, though I don't think there's as strong a case for deltalake to encourage that import pattern over just importing what you need. Pandas, NumPy, and Dask are libraries that have a big API where a user might need so many functions that importing them individually would be annoying. deltalake is much smaller; you typically just need DeltaTable and one or two more things. But I think it is common for data scientists/engineers to use the abbreviation import pattern.

My one worry is whether there is already another library that might use the dl abbreviation. pd, np, and dd are all universally recognized. I didn't see any packages used with dl when I googled, but something to think about.

MrPowers commented 2 years ago

@wjones127 - yea, I could go either way on this too. My opinion on import deltalake as dl being the "best" import pattern is weakly held.

I think this import pattern would help users avoid class name collisions between classes like DeltaTable that are defined in delta-rs & delta. That class name collusion actually tripped me up in the past.

Feel free to close this one or let me know if I should add a PR with this update. Thank you!