shackleton 0.0.1__tar.gz → 0.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {shackleton-0.0.1 → shackleton-0.0.2}/PKG-INFO +3 -2
- {shackleton-0.0.1 → shackleton-0.0.2}/shackleton/__init__.py +2 -1
- {shackleton-0.0.1 → shackleton-0.0.2}/shackleton/core.py +7 -3
- {shackleton-0.0.1 → shackleton-0.0.2}/shackleton/tests/test_core.py +17 -1
- {shackleton-0.0.1 → shackleton-0.0.2}/.github/workflows/test.yml +0 -0
- {shackleton-0.0.1 → shackleton-0.0.2}/.github/workflows/twine_release.yml +0 -0
- {shackleton-0.0.1 → shackleton-0.0.2}/.gitignore +0 -0
- {shackleton-0.0.1 → shackleton-0.0.2}/LICENSE +0 -0
- {shackleton-0.0.1 → shackleton-0.0.2}/README.md +0 -0
- {shackleton-0.0.1 → shackleton-0.0.2}/pyproject.toml +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: shackleton
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.2
|
|
4
4
|
Summary: Polars based database
|
|
5
5
|
Author-email: Endre Márk Borza <endremborza@gmail.com>
|
|
6
6
|
Requires-Python: >=3.10
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
8
9
|
Requires-Dist: polars
|
|
9
10
|
Requires-Dist: branthebuilder[doc] ; extra == "doc"
|
|
10
11
|
Requires-Dist: branthebuilder ; extra == "test"
|
|
@@ -27,7 +27,10 @@ class TableShack:
|
|
|
27
27
|
return self._write_meta(df, self._replace_records)
|
|
28
28
|
|
|
29
29
|
def lazy_read(self, path: Path) -> pl.LazyFrame:
|
|
30
|
-
|
|
30
|
+
if self.ipc:
|
|
31
|
+
o = pl.scan_ipc(path)
|
|
32
|
+
else:
|
|
33
|
+
o = pl.scan_parquet(path, hive_partitioning=False)
|
|
31
34
|
if self.id_col:
|
|
32
35
|
return o.set_sorted(self.id_col)
|
|
33
36
|
return o
|
|
@@ -77,6 +80,7 @@ class TableShack:
|
|
|
77
80
|
return pl.concat([old_df, df])
|
|
78
81
|
|
|
79
82
|
def _replace_records(self, df: pl.LazyFrame, old_df: pl.LazyFrame) -> pl.LazyFrame:
|
|
83
|
+
assert self.id_col is not None, "can only replace id'd records"
|
|
80
84
|
return old_df.merge_sorted(df, key=self.id_col).unique(
|
|
81
85
|
subset=self.id_col, keep="last"
|
|
82
86
|
)
|
|
@@ -85,7 +89,7 @@ class TableShack:
|
|
|
85
89
|
self,
|
|
86
90
|
df: pl.DataFrame,
|
|
87
91
|
fun: Callable[[pl.LazyFrame, pl.LazyFrame], pl.LazyFrame],
|
|
88
|
-
subdirs: tuple[str] = (),
|
|
92
|
+
subdirs: tuple[str, ...] = (),
|
|
89
93
|
partitioned=False,
|
|
90
94
|
):
|
|
91
95
|
if self.partition_cols and not partitioned:
|
|
@@ -103,7 +107,7 @@ class TableShack:
|
|
|
103
107
|
self._add_compression(fun)(out, true_path)
|
|
104
108
|
|
|
105
109
|
def _gb_handle(self, df: pl.DataFrame, fun):
|
|
106
|
-
for gid, gdf in df.
|
|
110
|
+
for gid, gdf in df.group_by(self.partition_cols):
|
|
107
111
|
hive_names = [f"{k}={v}" for k, v in zip(self.partition_cols, gid)]
|
|
108
112
|
self._write_meta(gdf.drop(self.partition_cols), fun, hive_names, True)
|
|
109
113
|
|
|
@@ -37,4 +37,20 @@ def test_import(tmp_path, id_col, comp):
|
|
|
37
37
|
shack.replace_records(df)
|
|
38
38
|
assert shack.get_full_df().shape[0] == df.shape[0]
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
some_dfs = False
|
|
41
|
+
for _df in shack.dfs:
|
|
42
|
+
assert _df.shape[0] > 0
|
|
43
|
+
some_dfs = True
|
|
44
|
+
assert some_dfs
|
|
45
|
+
|
|
46
|
+
n2 = 5678
|
|
47
|
+
df2 = pl.DataFrame(
|
|
48
|
+
{
|
|
49
|
+
"A": [rng.random() for _ in range(n2)],
|
|
50
|
+
"B": [rng.randint(0, 19) for _ in range(n2)],
|
|
51
|
+
"C": [rng.choice(byte_set) for _ in range(n2)],
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
shack.extend(df2)
|
|
56
|
+
assert shack.get_full_df().shape[0] == (n + n2)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|