duckrun 0.1.5.2__py3-none-any.whl → 0.1.5.3__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 CHANGED
@@ -111,16 +111,17 @@ class Duckrun:
111
111
 
112
112
  Usage:
113
113
  # For pipelines:
114
- dr = Duckrun.connect(workspace, lakehouse, schema, sql_folder)
114
+ dr = Duckrun.connect("workspace/lakehouse.lakehouse/schema", sql_folder="./sql")
115
+ dr = Duckrun.connect("workspace/lakehouse.lakehouse") # defaults to dbo schema
115
116
  dr.run(pipeline)
116
117
 
117
118
  # For data exploration with Spark-style API:
118
- dr = Duckrun.connect(workspace, lakehouse, schema)
119
+ dr = Duckrun.connect("workspace/lakehouse.lakehouse")
119
120
  dr.sql("SELECT * FROM table").show()
120
121
  dr.sql("SELECT 43").write.mode("append").saveAsTable("test")
121
122
  """
122
123
 
123
- def __init__(self, workspace: str, lakehouse_name: str, schema: str,
124
+ def __init__(self, workspace: str, lakehouse_name: str, schema: str = "dbo",
124
125
  sql_folder: Optional[str] = None, compaction_threshold: int = 10):
125
126
  self.workspace = workspace
126
127
  self.lakehouse_name = lakehouse_name
@@ -133,10 +134,57 @@ class Duckrun:
133
134
  self._attach_lakehouse()
134
135
 
135
136
  @classmethod
136
- def connect(cls, workspace: str, lakehouse_name: str, schema: str,
137
- sql_folder: Optional[str] = None, compaction_threshold: int = 100):
138
- """Create and connect to lakehouse"""
137
+ def connect(cls, workspace: Union[str, None] = None, lakehouse_name: Optional[str] = None,
138
+ schema: str = "dbo", sql_folder: Optional[str] = None,
139
+ compaction_threshold: int = 100):
140
+ """
141
+ Create and connect to lakehouse.
142
+
143
+ Supports two formats:
144
+ 1. Compact: connect("ws/lh.lakehouse/schema") or connect("ws/lh.lakehouse")
145
+ 2. Traditional: connect("ws", "lh", "schema") or connect("ws", "lh")
146
+
147
+ Schema defaults to "dbo" if not specified.
148
+
149
+ Examples:
150
+ dr = Duckrun.connect("myworkspace/mylakehouse.lakehouse/bronze")
151
+ dr = Duckrun.connect("myworkspace/mylakehouse.lakehouse") # uses dbo
152
+ dr = Duckrun.connect("myworkspace", "mylakehouse", "bronze")
153
+ dr = Duckrun.connect("myworkspace", "mylakehouse") # uses dbo
154
+ dr = Duckrun.connect("ws/lh.lakehouse", sql_folder="./sql")
155
+ """
139
156
  print("Connecting to Lakehouse...")
157
+
158
+ # Check if using compact format: "ws/lh.lakehouse/schema" or "ws/lh.lakehouse"
159
+ if workspace and "/" in workspace and lakehouse_name is None:
160
+ parts = workspace.split("/")
161
+ if len(parts) == 2:
162
+ # Format: "ws/lh.lakehouse" (schema will use default)
163
+ workspace, lakehouse_name = parts
164
+ # schema already has default value "dbo"
165
+ elif len(parts) == 3:
166
+ # Format: "ws/lh.lakehouse/schema"
167
+ workspace, lakehouse_name, schema = parts
168
+ else:
169
+ raise ValueError(
170
+ f"Invalid connection string format: '{workspace}'. "
171
+ "Expected format: 'workspace/lakehouse.lakehouse' or 'workspace/lakehouse.lakehouse/schema'"
172
+ )
173
+
174
+ # Remove .lakehouse suffix if present
175
+ if lakehouse_name.endswith(".lakehouse"):
176
+ lakehouse_name = lakehouse_name[:-10]
177
+
178
+ # Validate all required parameters are present
179
+ if not workspace or not lakehouse_name:
180
+ raise ValueError(
181
+ "Missing required parameters. Use either:\n"
182
+ " connect('workspace/lakehouse.lakehouse/schema')\n"
183
+ " connect('workspace/lakehouse.lakehouse') # defaults to dbo\n"
184
+ " connect('workspace', 'lakehouse', 'schema')\n"
185
+ " connect('workspace', 'lakehouse') # defaults to dbo"
186
+ )
187
+
140
188
  return cls(workspace, lakehouse_name, schema, sql_folder, compaction_threshold)
141
189
 
142
190
  def _get_storage_token(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: duckrun
3
- Version: 0.1.5.2
3
+ Version: 0.1.5.3
4
4
  Summary: Lakehouse task runner powered by DuckDB for Microsoft Fabric
5
5
  Author: mim
6
6
  License-Expression: MIT
@@ -0,0 +1,7 @@
1
+ duckrun/__init__.py,sha256=L0jRtD9Ld8Ti4e6GRvPDdHvkQCFAPHM43GSP7ARh6EM,241
2
+ duckrun/core.py,sha256=n4FqyWlPFRnC-BBMphnOCzxrad4FwTTgl7lTfWL7AEk,20525
3
+ duckrun-0.1.5.3.dist-info/licenses/LICENSE,sha256=-DeQQwdbCbkB4507ZF3QbocysB-EIjDtaLexvqRkGZc,1083
4
+ duckrun-0.1.5.3.dist-info/METADATA,sha256=1ibXy62hbaRBlw7br1UIUUCkVw0AsZxao1cl-0hWitg,7792
5
+ duckrun-0.1.5.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ duckrun-0.1.5.3.dist-info/top_level.txt,sha256=BknMEwebbUHrVAp3SC92ps8MPhK7XSYsaogTvi_DmEU,8
7
+ duckrun-0.1.5.3.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- duckrun/__init__.py,sha256=L0jRtD9Ld8Ti4e6GRvPDdHvkQCFAPHM43GSP7ARh6EM,241
2
- duckrun/core.py,sha256=EoXlQsx7i3BS2a26zB90n4xDBy_WQu1sNicPNYU3DgY,18110
3
- duckrun-0.1.5.2.dist-info/licenses/LICENSE,sha256=-DeQQwdbCbkB4507ZF3QbocysB-EIjDtaLexvqRkGZc,1083
4
- duckrun-0.1.5.2.dist-info/METADATA,sha256=UWtYkoj5E5CsqHKUiJOOVJTQywdTsyzoJpnbiAd28cI,7792
5
- duckrun-0.1.5.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
- duckrun-0.1.5.2.dist-info/top_level.txt,sha256=BknMEwebbUHrVAp3SC92ps8MPhK7XSYsaogTvi_DmEU,8
7
- duckrun-0.1.5.2.dist-info/RECORD,,