duckrun 0.1.1__py3-none-any.whl → 0.1.2__py3-none-any.whl
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.
- duckrun/core.py +15 -1
- {duckrun-0.1.1.dist-info → duckrun-0.1.2.dist-info}/METADATA +14 -29
- duckrun-0.1.2.dist-info/RECORD +7 -0
- duckrun-0.1.1.dist-info/RECORD +0 -7
- {duckrun-0.1.1.dist-info → duckrun-0.1.2.dist-info}/WHEEL +0 -0
- {duckrun-0.1.1.dist-info → duckrun-0.1.2.dist-info}/licenses/LICENSE +0 -0
- {duckrun-0.1.1.dist-info → duckrun-0.1.2.dist-info}/top_level.txt +0 -0
duckrun/core.py
CHANGED
@@ -64,9 +64,14 @@ class Duckrun:
|
|
64
64
|
def _attach_lakehouse(self):
|
65
65
|
self._create_onelake_secret()
|
66
66
|
try:
|
67
|
+
# Exclude Iceberg metadata folders when scanning for Delta tables
|
67
68
|
list_tables_query = f"""
|
68
69
|
SELECT DISTINCT(split_part(file, '_delta_log', 1)) as tables
|
69
70
|
FROM glob ("abfss://{self.workspace}@onelake.dfs.fabric.microsoft.com/{self.lakehouse_name}.Lakehouse/Tables/*/*/_delta_log/*.json")
|
71
|
+
WHERE file NOT LIKE '%/metadata/%'
|
72
|
+
AND file NOT LIKE '%/iceberg/%'
|
73
|
+
AND split_part(file, '_delta_log', 1) NOT LIKE '%/metadata'
|
74
|
+
AND split_part(file, '_delta_log', 1) NOT LIKE '%/iceberg'
|
70
75
|
"""
|
71
76
|
list_tables_df = self.con.sql(list_tables_query).df()
|
72
77
|
list_tables = list_tables_df['tables'].tolist() if not list_tables_df.empty else []
|
@@ -82,18 +87,27 @@ class Duckrun:
|
|
82
87
|
if len(parts) >= 2:
|
83
88
|
potential_schema = parts[-2]
|
84
89
|
table = parts[-1]
|
90
|
+
|
91
|
+
# Skip Iceberg-related folders
|
92
|
+
if table in ('metadata', 'iceberg') or potential_schema in ('metadata', 'iceberg'):
|
93
|
+
continue
|
94
|
+
|
85
95
|
if potential_schema == self.schema:
|
86
96
|
try:
|
87
97
|
self.con.sql(f"""
|
88
98
|
CREATE OR REPLACE VIEW {table}
|
89
99
|
AS SELECT * FROM delta_scan('{self.table_base_url}{self.schema}/{table}');
|
90
100
|
""")
|
101
|
+
print(f" ✓ Attached: {table}")
|
91
102
|
except Exception as e:
|
92
|
-
print(f"
|
103
|
+
print(f" ⚠ Skipped {table}: {str(e)[:100]}")
|
104
|
+
continue
|
105
|
+
|
93
106
|
print("\nAttached tables (views) in DuckDB:")
|
94
107
|
self.con.sql("SELECT name FROM (SHOW ALL TABLES) WHERE database='memory'").show()
|
95
108
|
except Exception as e:
|
96
109
|
print(f"Error attaching lakehouse: {e}")
|
110
|
+
print("Continuing without pre-attached tables.")
|
97
111
|
|
98
112
|
def _normalize_table_name(self, name: str) -> str:
|
99
113
|
"""Extract base table name before first '__'"""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: duckrun
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.2
|
4
4
|
Summary: Lakehouse task runner powered by DuckDB for Microsoft Fabric
|
5
5
|
License-Expression: MIT
|
6
6
|
Project-URL: Homepage, https://github.com/djouallah/duckrun
|
@@ -14,10 +14,16 @@ Requires-Dist: deltalake>=0.18.2
|
|
14
14
|
Requires-Dist: requests>=2.28.0
|
15
15
|
Dynamic: license-file
|
16
16
|
|
17
|
-
|
17
|
+
|
18
|
+
<img src="duckrun.png" width="400" alt="Duckrun">
|
18
19
|
|
19
20
|
Simple task runner for Microsoft Fabric Python notebook, powered by DuckDB and Delta_rs.
|
20
21
|
|
22
|
+
|
23
|
+
## Known Limitation
|
24
|
+
|
25
|
+
Support only Lakehouse with schema, Workspace and lakehouse names should not contains space
|
26
|
+
|
21
27
|
## Installation
|
22
28
|
|
23
29
|
```bash
|
@@ -50,6 +56,10 @@ pipeline = [
|
|
50
56
|
lakehouse.run(pipeline)
|
51
57
|
```
|
52
58
|
|
59
|
+
## Early Exit
|
60
|
+
|
61
|
+
In a pipeline run, if a task fails, the pipeline will stop without running the subsequent tasks.
|
62
|
+
|
53
63
|
## How It Works
|
54
64
|
|
55
65
|
Duckrun runs two types of tasks:
|
@@ -117,8 +127,8 @@ Use `__` to create variants of the same table:
|
|
117
127
|
|
118
128
|
```python
|
119
129
|
pipeline = [
|
120
|
-
('sales__initial', 'overwrite'
|
121
|
-
('sales__incremental', 'append'
|
130
|
+
('sales__initial', 'overwrite'), # writes to 'sales' table
|
131
|
+
('sales__incremental', 'append'), # appends to 'sales' table
|
122
132
|
]
|
123
133
|
```
|
124
134
|
|
@@ -134,32 +144,7 @@ lakehouse.sql("SELECT * FROM my_table LIMIT 10").show()
|
|
134
144
|
df = lakehouse.sql("SELECT COUNT(*) FROM sales").df()
|
135
145
|
```
|
136
146
|
|
137
|
-
## Real-World Example
|
138
147
|
|
139
|
-
```python
|
140
|
-
import duckrun as dr
|
141
|
-
|
142
|
-
lakehouse = dr.connect(
|
143
|
-
workspace="Analytics",
|
144
|
-
lakehouse_name="Sales",
|
145
|
-
schema="dbo",
|
146
|
-
sql_folder="./etl"
|
147
|
-
)
|
148
|
-
|
149
|
-
# Daily pipeline
|
150
|
-
daily = [
|
151
|
-
('download_files', (api_url, local_path)),
|
152
|
-
('staging_orders', 'overwrite', {'run_date': '2024-06-01'}),
|
153
|
-
('staging_customers', 'overwrite', {'run_date': '2024-06-01'}),
|
154
|
-
('fact_sales', 'append'),
|
155
|
-
('dim_customer', 'overwrite')
|
156
|
-
]
|
157
|
-
|
158
|
-
lakehouse.run(daily)
|
159
|
-
|
160
|
-
# Check results
|
161
|
-
lakehouse.sql("SELECT COUNT(*) FROM fact_sales").show()
|
162
|
-
```
|
163
148
|
|
164
149
|
## Remote SQL Files
|
165
150
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
duckrun/__init__.py,sha256=L0jRtD9Ld8Ti4e6GRvPDdHvkQCFAPHM43GSP7ARh6EM,241
|
2
|
+
duckrun/core.py,sha256=GvOPfrPBkqn4fUxMZLLu7QcWaJifViPlyRrHwKfGQTU,13883
|
3
|
+
duckrun-0.1.2.dist-info/licenses/LICENSE,sha256=-DeQQwdbCbkB4507ZF3QbocysB-EIjDtaLexvqRkGZc,1083
|
4
|
+
duckrun-0.1.2.dist-info/METADATA,sha256=kd0HnT4a20kJ4_bBMsUtblrkmiFXF025zmdYmsj2B1s,3805
|
5
|
+
duckrun-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
+
duckrun-0.1.2.dist-info/top_level.txt,sha256=BknMEwebbUHrVAp3SC92ps8MPhK7XSYsaogTvi_DmEU,8
|
7
|
+
duckrun-0.1.2.dist-info/RECORD,,
|
duckrun-0.1.1.dist-info/RECORD
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
duckrun/__init__.py,sha256=L0jRtD9Ld8Ti4e6GRvPDdHvkQCFAPHM43GSP7ARh6EM,241
|
2
|
-
duckrun/core.py,sha256=-Vf2nYwhdsVpTZS9mGBtm8j_HNAcHR7Cj075pida3Yw,13133
|
3
|
-
duckrun-0.1.1.dist-info/licenses/LICENSE,sha256=-DeQQwdbCbkB4507ZF3QbocysB-EIjDtaLexvqRkGZc,1083
|
4
|
-
duckrun-0.1.1.dist-info/METADATA,sha256=4KZAURlPgjIDGYW_htE4gdHLi6WX-3gpfrCY0r1sFPE,4114
|
5
|
-
duckrun-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
-
duckrun-0.1.1.dist-info/top_level.txt,sha256=BknMEwebbUHrVAp3SC92ps8MPhK7XSYsaogTvi_DmEU,8
|
7
|
-
duckrun-0.1.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|