Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/source/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## 0.6.5 (2026-01-DD)
## 0.7.0 (2026-01-DD)
- disable printing of table data for SQL backends (issue #100 is to make this configurable)
- fix sqlalchemy deprecation warnings

## 0.6.4 (2025-12-18)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pydiverse-transform"
version = "0.6.4"
version = "0.7.0"
description = "Pipe based dataframe manipulation library that can also transform data on SQL databases"
authors = [
{ name = "QuantCo, Inc." },
Expand Down
34 changes: 19 additions & 15 deletions src/pydiverse/transform/_internal/pipe/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,25 +257,29 @@ def __repr__(self) -> str:
res = tbl_name + f"(backend: {self._cache.backend.backend_name})\n"

try:
df, height = get_head_tail(self)
res += f"shape: ({height}, {len(self)})\n"

except Exception as e:
try:
ast = repr(self._ast)
except Exception:
ast = ""
return res + f"export failed\n{type(e).__name__}: {str(e)}\n{ast}"
ast = repr(self._ast)
except Exception:
ast = ""

try:
query = self >> build_query()
if query is None:
query = ""
else:
if query is not None:
query = "\n\nQuery:\n" + query
except Exception:
query = ""
return res + str(df).split("\n", 1)[1] + query
else:
query = ""
except Exception as e:
return res + f"building query failed\n{type(e).__name__}: {str(e)}\n{ast}"

df_str = ""
if query == "":
# consider making it configurable to show both query and df_str for sql backends
try:
df, height = get_head_tail(self)
res += f"shape: ({height}, {len(self)})\n"
df_str = str(df).split("\n", 1)[1]
except Exception as e:
return res + f"export failed\n{type(e).__name__}: {str(e)}\n{ast}"
return res + df_str + query

def __dir__(self) -> list[str]:
return [name for name in self._cache.name_to_uuid.keys()]
Expand Down
12 changes: 6 additions & 6 deletions tests/test_backend_equivalence/test_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@


def test_preview_print(df3, df4, df_strings):
def data_part(p: str):
return p.split("\n", 1)[1].split("\n\n", 1)[0]

assert data_part(str(df3[0])) == data_part(str(df3[1]))
assert data_part(str(df_strings[0])) == data_part(str(df_strings[1]))
# # might be needed again once SQL data print is configurable
# def data_part(p: str):
# return p.split("\n", 1)[1].split("\n\n", 1)[0]
# assert data_part(str(df3[0])) == data_part(str(df3[1]))

long_tbl = [
# after a join, the order is arbitrary, so we need to enforce a specific order
left >> cross_join(right) >> arrange(left.col4, right.col4.nulls_last())
for left, right in zip(df3, df4, strict=True)
]
assert data_part(str(long_tbl[0])) == data_part(str(long_tbl[1]))
for df in df3, df4, df_strings, long_tbl:
assert str(df[0] >> export(Polars)) == str(df[1] >> export(Polars))