laketower 0.6.3__py3-none-any.whl → 0.6.5__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.

Potentially problematic release.


This version of laketower might be problematic. Click here for more details.

laketower/__about__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.6.3"
1
+ __version__ = "0.6.5"
laketower/cli.py CHANGED
@@ -1,9 +1,11 @@
1
1
  import argparse
2
2
  import os
3
+ import time
3
4
  from pathlib import Path
4
5
 
5
6
  import rich.jupyter
6
7
  import rich.panel
8
+ import rich.style
7
9
  import rich.table
8
10
  import rich.text
9
11
  import rich.tree
@@ -20,6 +22,7 @@ from laketower.tables import (
20
22
  generate_table_query,
21
23
  generate_table_statistics_query,
22
24
  import_file_to_table,
25
+ limit_query,
23
26
  load_datasets,
24
27
  load_table,
25
28
  )
@@ -194,9 +197,27 @@ def query_table(
194
197
  query_params = {
195
198
  name: sql_params_dict.get(name) or "" for name in query_param_names
196
199
  }
197
- results = execute_query(tables_dataset, sql_query, sql_params=query_params)
200
+ limited_sql_query = limit_query(sql_query, config.settings.max_query_rows + 1)
198
201
 
199
- out = rich.table.Table()
202
+ start_time = time.perf_counter()
203
+ results = execute_query(
204
+ tables_dataset, limited_sql_query, sql_params=query_params
205
+ )
206
+ execution_time_ms = (time.perf_counter() - start_time) * 1000
207
+
208
+ truncated = results.num_rows > config.settings.max_query_rows
209
+ results = results.slice(
210
+ 0, min(results.num_rows, config.settings.max_query_rows)
211
+ )
212
+
213
+ out = rich.table.Table(
214
+ caption=(
215
+ f"{results.num_rows} rows returned{' (truncated)' if truncated else ''}"
216
+ f"\nExecution time: {execution_time_ms:.2f}ms"
217
+ ),
218
+ caption_justify="left",
219
+ caption_style=rich.style.Style(dim=True),
220
+ )
200
221
  for column in results.column_names:
201
222
  out.add_column(column)
202
223
  for row_dict in results.to_pylist():
@@ -268,9 +289,27 @@ def view_query(
268
289
  name: query_params_dict.get(name) or default_parameters.get(name) or ""
269
290
  for name in sql_param_names
270
291
  }
271
- results = execute_query(tables_dataset, sql_query, sql_params=sql_params)
292
+ limited_sql_query = limit_query(sql_query, config.settings.max_query_rows + 1)
272
293
 
273
- out = rich.table.Table()
294
+ start_time = time.perf_counter()
295
+ results = execute_query(
296
+ tables_dataset, limited_sql_query, sql_params=sql_params
297
+ )
298
+ execution_time_ms = (time.perf_counter() - start_time) * 1000
299
+
300
+ truncated = results.num_rows > config.settings.max_query_rows
301
+ results = results.slice(
302
+ 0, min(results.num_rows, config.settings.max_query_rows)
303
+ )
304
+
305
+ out = rich.table.Table(
306
+ caption=(
307
+ f"{results.num_rows} rows returned{' (truncated)' if truncated else ''}"
308
+ f"\nExecution time: {execution_time_ms:.2f}ms"
309
+ ),
310
+ caption_justify="left",
311
+ caption_style=rich.style.Style(dim=True),
312
+ )
274
313
  for column in results.column_names:
275
314
  out.add_column(column)
276
315
  for row_dict in results.to_pylist():
laketower/config.py CHANGED
@@ -89,6 +89,15 @@ class ConfigTableConnection(pydantic.BaseModel):
89
89
  return self
90
90
 
91
91
 
92
+ class ConfigSettingsWeb(pydantic.BaseModel):
93
+ hide_tables: bool = False
94
+
95
+
96
+ class ConfigSettings(pydantic.BaseModel):
97
+ max_query_rows: int = 1_000
98
+ web: ConfigSettingsWeb = ConfigSettingsWeb()
99
+
100
+
92
101
  class ConfigTable(pydantic.BaseModel):
93
102
  name: str
94
103
  uri: str
@@ -109,6 +118,7 @@ class ConfigQuery(pydantic.BaseModel):
109
118
 
110
119
 
111
120
  class Config(pydantic.BaseModel):
121
+ settings: ConfigSettings = ConfigSettings()
112
122
  tables: list[ConfigTable] = []
113
123
  queries: list[ConfigQuery] = []
114
124