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] append column with a in-memory Pyarrow Table #338

Merged
merged 3 commits into from
Dec 1, 2022

Conversation

eddyxu
Copy link
Contributor

@eddyxu eddyxu commented Nov 30, 2022

Closes #320

@eddyxu eddyxu requested a review from changhiskhan November 30, 2022 18:53
@eddyxu eddyxu marked this pull request as ready for review November 30, 2022 18:53
@eddyxu eddyxu self-assigned this Nov 30, 2022
@eddyxu eddyxu added the python label Nov 30, 2022
@eddyxu eddyxu changed the title [Python] append column with a table [Python] append column with a in-memory Pyarrow Table Nov 30, 2022
def append_column(
self,
field: Field,
value: Union[Callable[[pyarrow.Table], pyarrow.Array], Expression],
value: Union[Callable[[pyarrow.Table], pyarrow.Array], Expression, pyarrow.Table],
Copy link
Contributor

Choose a reason for hiding this comment

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

if we're merging the whole table then we can't call this append_column.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we create a dataset.merge method? For now, limit it to horizontal concat. But later on we can allow for appending rows and columns in one shot? Pandas has this functionality, though the pandas merge API is way too complicated. wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, i will make this a separate Merge function.

@@ -46,7 +49,9 @@ def value_func(x: pa.Table):
assert x.column_names == ["a"]
return pa.array([str(i) for i in x.column("a")])

new_dataset = dataset.append_column(pa.field("c", pa.utf8()), value_func, columns=["a"])
new_dataset = dataset.append_column(
value_func, field=pa.field("c", pa.utf8()), columns=["a"]
Copy link
Contributor

Choose a reason for hiding this comment

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

you know now that i'm looking at this API, having field and columns is really going to confuse people.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about change columns to select ?

Copy link
Contributor

@changhiskhan changhiskhan left a comment

Choose a reason for hiding this comment

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

pending #337

Base automatically changed from lei/hash_merge to main December 1, 2022 23:01
@eddyxu eddyxu force-pushed the lei/py_merge_table branch from 074c77d to dc14a81 Compare December 1, 2022 23:07
@eddyxu eddyxu merged commit 741957f into main Dec 1, 2022
@eddyxu eddyxu deleted the lei/py_merge_table branch December 1, 2022 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Append column takes a already-computed array.
2 participants