meerschaum 2.4.11__py3-none-any.whl → 2.4.12__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.
- meerschaum/_internal/arguments/_parse_arguments.py +15 -1
- meerschaum/_internal/docs/index.py +1 -0
- meerschaum/_internal/shell/Shell.py +19 -9
- meerschaum/_internal/shell/ShellCompleter.py +11 -6
- meerschaum/actions/bootstrap.py +120 -15
- meerschaum/actions/clear.py +41 -30
- meerschaum/actions/edit.py +89 -0
- meerschaum/actions/start.py +3 -2
- meerschaum/api/dash/callbacks/dashboard.py +2 -1
- meerschaum/api/dash/callbacks/jobs.py +53 -7
- meerschaum/api/dash/callbacks/pipes.py +1 -1
- meerschaum/api/dash/jobs.py +86 -60
- meerschaum/api/dash/pages/__init__.py +1 -0
- meerschaum/api/dash/pages/job.py +21 -0
- meerschaum/api/routes/_jobs.py +3 -3
- meerschaum/config/_version.py +1 -1
- meerschaum/connectors/sql/_fetch.py +65 -61
- meerschaum/connectors/sql/_pipes.py +36 -29
- meerschaum/utils/formatting/__init__.py +32 -16
- meerschaum/utils/formatting/_pipes.py +1 -1
- meerschaum/utils/formatting/_shell.py +4 -3
- meerschaum/utils/prompt.py +16 -15
- meerschaum/utils/sql.py +107 -35
- {meerschaum-2.4.11.dist-info → meerschaum-2.4.12.dist-info}/METADATA +1 -1
- {meerschaum-2.4.11.dist-info → meerschaum-2.4.12.dist-info}/RECORD +31 -30
- {meerschaum-2.4.11.dist-info → meerschaum-2.4.12.dist-info}/WHEEL +1 -1
- {meerschaum-2.4.11.dist-info → meerschaum-2.4.12.dist-info}/LICENSE +0 -0
- {meerschaum-2.4.11.dist-info → meerschaum-2.4.12.dist-info}/NOTICE +0 -0
- {meerschaum-2.4.11.dist-info → meerschaum-2.4.12.dist-info}/entry_points.txt +0 -0
- {meerschaum-2.4.11.dist-info → meerschaum-2.4.12.dist-info}/top_level.txt +0 -0
- {meerschaum-2.4.11.dist-info → meerschaum-2.4.12.dist-info}/zip-safe +0 -0
@@ -26,7 +26,7 @@ html, dcc = import_html(check_update=CHECK_UPDATE), import_dcc(check_update=CHEC
|
|
26
26
|
State('pipes-location', 'search'),
|
27
27
|
State('session-store', 'data'),
|
28
28
|
)
|
29
|
-
def
|
29
|
+
def render_pipe_page_from_url(
|
30
30
|
pathname: str,
|
31
31
|
pipe_search: str,
|
32
32
|
session_data: Optional[Dict[str, Any]],
|
meerschaum/api/dash/jobs.py
CHANGED
@@ -31,6 +31,7 @@ STATUS_EMOJI: Dict[str, str] = {
|
|
31
31
|
|
32
32
|
EXECUTOR_KEYS: str = get_executor_keys_from_context()
|
33
33
|
|
34
|
+
|
34
35
|
def get_jobs_cards(state: WebState):
|
35
36
|
"""
|
36
37
|
Build cards and alerts lists for jobs.
|
@@ -42,71 +43,96 @@ def get_jobs_cards(state: WebState):
|
|
42
43
|
cards = []
|
43
44
|
|
44
45
|
for name, job in jobs.items():
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
46
|
+
cards.append(build_job_card(job, authenticated=is_authenticated))
|
47
|
+
|
48
|
+
return cards, []
|
49
|
+
|
50
|
+
|
51
|
+
def build_job_card(
|
52
|
+
job: Job,
|
53
|
+
authenticated: bool = False,
|
54
|
+
include_follow: bool = True,
|
55
|
+
):
|
56
|
+
"""
|
57
|
+
Return a card for a given job.
|
58
|
+
"""
|
59
|
+
footer_children = html.Div(
|
60
|
+
build_process_timestamps_children(job),
|
61
|
+
id={'type': 'process-timestamps-div', 'index': job.name},
|
62
|
+
)
|
63
|
+
follow_logs_button = dbc.DropdownMenuItem(
|
64
|
+
"Follow logs",
|
65
|
+
id={'type': 'follow-logs-button', 'index': job.name},
|
66
|
+
)
|
67
|
+
download_logs_button = dbc.DropdownMenuItem(
|
68
|
+
"Download logs",
|
69
|
+
id={'type': 'job-download-logs-button', 'index': job.name},
|
70
|
+
)
|
71
|
+
logs_menu_children = (
|
72
|
+
([follow_logs_button] if include_follow else []) + [download_logs_button]
|
73
|
+
if authenticated
|
74
|
+
else []
|
75
|
+
)
|
76
|
+
header_children = [
|
77
|
+
html.Div(
|
78
|
+
build_status_children(job),
|
79
|
+
id={'type': 'manage-job-status-div', 'index': job.name},
|
80
|
+
style={'float': 'left'},
|
81
|
+
),
|
82
|
+
] + ([
|
83
|
+
html.Div(
|
84
|
+
dbc.DropdownMenu(
|
85
|
+
logs_menu_children,
|
86
|
+
label="Logs",
|
87
|
+
size="sm",
|
88
|
+
align_end=True,
|
89
|
+
color="secondary",
|
90
|
+
menu_variant='dark',
|
65
91
|
),
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
92
|
+
style={'float': 'right'},
|
93
|
+
),
|
94
|
+
] if authenticated else [])
|
95
|
+
|
96
|
+
body_children = [
|
97
|
+
html.H4(
|
98
|
+
html.B(
|
99
|
+
html.A(
|
100
|
+
"🔗 " + job.name,
|
101
|
+
href=f"/dash/job/{job.name}",
|
102
|
+
target="_blank",
|
103
|
+
style={
|
104
|
+
'color': 'white',
|
105
|
+
'text-decoration': 'none',
|
106
|
+
},
|
107
|
+
)
|
76
108
|
),
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
html.
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
style={"word-wrap": "break-word"},
|
86
|
-
id={'type': 'job-label-p', 'index': name},
|
87
|
-
),
|
88
|
-
style={"white-space": "pre-wrap"},
|
109
|
+
className="card-title",
|
110
|
+
),
|
111
|
+
html.Div(
|
112
|
+
html.P(
|
113
|
+
job.label,
|
114
|
+
className="card-text job-card-text",
|
115
|
+
style={"word-wrap": "break-word"},
|
116
|
+
id={'type': 'job-label-p', 'index': job.name},
|
89
117
|
),
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
118
|
+
style={"white-space": "pre-wrap"},
|
119
|
+
),
|
120
|
+
html.Div(
|
121
|
+
(
|
122
|
+
build_manage_job_buttons_div_children(job)
|
123
|
+
if authenticated
|
124
|
+
else []
|
97
125
|
),
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
dbc.Card([
|
103
|
-
dbc.CardHeader(header_children),
|
104
|
-
dbc.CardBody(body_children),
|
105
|
-
dbc.CardFooter(footer_children),
|
106
|
-
])
|
107
|
-
)
|
126
|
+
id={'type': 'manage-job-buttons-div', 'index': job.name},
|
127
|
+
),
|
128
|
+
html.Div(id={'type': 'manage-job-alert-div', 'index': job.name}),
|
129
|
+
]
|
108
130
|
|
109
|
-
return
|
131
|
+
return dbc.Card([
|
132
|
+
dbc.CardHeader(header_children),
|
133
|
+
dbc.CardBody(body_children),
|
134
|
+
dbc.CardFooter(footer_children),
|
135
|
+
])
|
110
136
|
|
111
137
|
|
112
138
|
def build_manage_job_buttons_div_children(job: Job):
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#! /usr/bin/env python3
|
2
|
+
# vim:fenc=utf-8
|
3
|
+
|
4
|
+
"""
|
5
|
+
Display pipes via a shareable URL.
|
6
|
+
"""
|
7
|
+
|
8
|
+
from meerschaum.api import CHECK_UPDATE
|
9
|
+
from meerschaum.utils.packages import import_html, import_dcc
|
10
|
+
|
11
|
+
html, dcc = import_html(check_update=CHECK_UPDATE), import_dcc(check_update=CHECK_UPDATE)
|
12
|
+
import dash_bootstrap_components as dbc
|
13
|
+
|
14
|
+
from meerschaum.api.dash.components import download_logs, refresh_jobs_interval
|
15
|
+
|
16
|
+
layout = dbc.Container([
|
17
|
+
dcc.Location('job-location'),
|
18
|
+
html.Div(id='job-output-div'),
|
19
|
+
download_logs,
|
20
|
+
refresh_jobs_interval,
|
21
|
+
])
|
meerschaum/api/routes/_jobs.py
CHANGED
@@ -39,12 +39,12 @@ NONINTERACTIVE_ENV: str = STATIC_CONFIG['environment']['noninteractive']
|
|
39
39
|
EXECUTOR_KEYS: str = 'local'
|
40
40
|
|
41
41
|
|
42
|
-
def _get_job(name: str):
|
43
|
-
systemd_job = Job(name, executor_keys='systemd')
|
42
|
+
def _get_job(name: str, sysargs: Union[str, List[str], None] = None):
|
43
|
+
systemd_job = Job(name, sysargs, executor_keys='systemd')
|
44
44
|
if systemd_job.exists():
|
45
45
|
return systemd_job
|
46
46
|
|
47
|
-
job = Job(name, executor_keys=EXECUTOR_KEYS)
|
47
|
+
job = Job(name, sysargs, executor_keys=EXECUTOR_KEYS)
|
48
48
|
return job
|
49
49
|
|
50
50
|
|
meerschaum/config/_version.py
CHANGED
@@ -7,27 +7,29 @@ Implement the Connector fetch() method
|
|
7
7
|
"""
|
8
8
|
|
9
9
|
from __future__ import annotations
|
10
|
+
|
10
11
|
from datetime import datetime, timedelta
|
11
12
|
import meerschaum as mrsm
|
12
|
-
from meerschaum.utils.typing import Optional, Union, Callable, Any
|
13
|
+
from meerschaum.utils.typing import Optional, Union, Callable, Any, List, Dict
|
14
|
+
|
13
15
|
|
14
16
|
def fetch(
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
self,
|
18
|
+
pipe: mrsm.Pipe,
|
19
|
+
begin: Union[datetime, int, str, None] = '',
|
20
|
+
end: Union[datetime, int, str, None] = None,
|
21
|
+
check_existing: bool = True,
|
22
|
+
chunk_hook: Optional[Callable[['pd.DataFrame'], Any]] = None,
|
23
|
+
chunksize: Optional[int] = -1,
|
24
|
+
workers: Optional[int] = None,
|
25
|
+
debug: bool = False,
|
26
|
+
**kw: Any
|
27
|
+
) -> Union['pd.DataFrame', List[Any], None]:
|
26
28
|
"""Execute the SQL definition and return a Pandas DataFrame.
|
27
29
|
|
28
30
|
Parameters
|
29
31
|
----------
|
30
|
-
pipe:
|
32
|
+
pipe: mrsm.Pipe
|
31
33
|
The pipe object which contains the `fetch` metadata.
|
32
34
|
|
33
35
|
- pipe.columns['datetime']: str
|
@@ -63,7 +65,7 @@ def fetch(
|
|
63
65
|
|
64
66
|
debug: bool, default False
|
65
67
|
Verbosity toggle.
|
66
|
-
|
68
|
+
|
67
69
|
Returns
|
68
70
|
-------
|
69
71
|
A pandas DataFrame or `None`.
|
@@ -71,20 +73,20 @@ def fetch(
|
|
71
73
|
"""
|
72
74
|
meta_def = self.get_pipe_metadef(
|
73
75
|
pipe,
|
74
|
-
begin
|
75
|
-
end
|
76
|
-
check_existing
|
77
|
-
debug
|
76
|
+
begin=begin,
|
77
|
+
end=end,
|
78
|
+
check_existing=check_existing,
|
79
|
+
debug=debug,
|
78
80
|
**kw
|
79
81
|
)
|
80
82
|
as_hook_results = chunk_hook is not None
|
81
83
|
chunks = self.read(
|
82
84
|
meta_def,
|
83
|
-
chunk_hook
|
84
|
-
as_hook_results
|
85
|
-
chunksize
|
86
|
-
workers
|
87
|
-
debug
|
85
|
+
chunk_hook=chunk_hook,
|
86
|
+
as_hook_results=as_hook_results,
|
87
|
+
chunksize=chunksize,
|
88
|
+
workers=workers,
|
89
|
+
debug=debug,
|
88
90
|
)
|
89
91
|
### if sqlite, parse for datetimes
|
90
92
|
if not as_hook_results and self.flavor == 'sqlite':
|
@@ -97,8 +99,8 @@ def fetch(
|
|
97
99
|
return (
|
98
100
|
parse_df_datetimes(
|
99
101
|
chunk,
|
100
|
-
ignore_cols
|
101
|
-
debug
|
102
|
+
ignore_cols=ignore_cols,
|
103
|
+
debug=debug,
|
102
104
|
)
|
103
105
|
for chunk in chunks
|
104
106
|
)
|
@@ -106,15 +108,15 @@ def fetch(
|
|
106
108
|
|
107
109
|
|
108
110
|
def get_pipe_metadef(
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
111
|
+
self,
|
112
|
+
pipe: mrsm.Pipe,
|
113
|
+
params: Optional[Dict[str, Any]] = None,
|
114
|
+
begin: Union[datetime, int, str, None] = '',
|
115
|
+
end: Union[datetime, int, str, None] = None,
|
116
|
+
check_existing: bool = True,
|
117
|
+
debug: bool = False,
|
118
|
+
**kw: Any
|
119
|
+
) -> Union[str, None]:
|
118
120
|
"""
|
119
121
|
Return a pipe's meta definition fetch query.
|
120
122
|
|
@@ -173,7 +175,6 @@ def get_pipe_metadef(
|
|
173
175
|
stack = False
|
174
176
|
)
|
175
177
|
|
176
|
-
|
177
178
|
apply_backtrack = begin == '' and check_existing
|
178
179
|
backtrack_interval = pipe.get_backtrack_interval(check_existing=check_existing, debug=debug)
|
179
180
|
btm = (
|
@@ -189,35 +190,34 @@ def get_pipe_metadef(
|
|
189
190
|
|
190
191
|
if begin and end and begin >= end:
|
191
192
|
begin = None
|
192
|
-
|
193
|
-
da = None
|
193
|
+
|
194
194
|
if dt_name:
|
195
195
|
begin_da = (
|
196
196
|
dateadd_str(
|
197
|
-
flavor
|
198
|
-
datepart
|
199
|
-
number
|
200
|
-
begin
|
197
|
+
flavor=self.flavor,
|
198
|
+
datepart='minute',
|
199
|
+
number=((-1 * btm) if apply_backtrack else 0),
|
200
|
+
begin=begin,
|
201
201
|
)
|
202
202
|
if begin
|
203
203
|
else None
|
204
204
|
)
|
205
205
|
end_da = (
|
206
206
|
dateadd_str(
|
207
|
-
flavor
|
208
|
-
datepart
|
209
|
-
number
|
210
|
-
begin
|
207
|
+
flavor=self.flavor,
|
208
|
+
datepart='minute',
|
209
|
+
number=0,
|
210
|
+
begin=end,
|
211
211
|
)
|
212
212
|
if end
|
213
213
|
else None
|
214
214
|
)
|
215
215
|
|
216
216
|
meta_def = (
|
217
|
-
_simple_fetch_query(pipe) if (
|
217
|
+
_simple_fetch_query(pipe, self.flavor) if (
|
218
218
|
(not (pipe.columns or {}).get('id', None))
|
219
219
|
or (not get_config('system', 'experimental', 'join_fetch'))
|
220
|
-
) else _join_fetch_query(pipe, debug=debug, **kw)
|
220
|
+
) else _join_fetch_query(pipe, self.flavor, debug=debug, **kw)
|
221
221
|
)
|
222
222
|
|
223
223
|
has_where = 'where' in meta_def.lower()[meta_def.lower().rfind('definition'):]
|
@@ -300,25 +300,28 @@ def set_pipe_query(pipe: mrsm.Pipe, query: str) -> None:
|
|
300
300
|
dict_to_set[key_to_set] = query
|
301
301
|
|
302
302
|
|
303
|
-
def _simple_fetch_query(
|
303
|
+
def _simple_fetch_query(
|
304
|
+
pipe: mrsm.Pipe,
|
305
|
+
flavor: str,
|
306
|
+
debug: bool = False,
|
307
|
+
**kw
|
308
|
+
) -> str:
|
304
309
|
"""Build a fetch query from a pipe's definition."""
|
305
|
-
|
310
|
+
from meerschaum.utils.sql import format_cte_subquery
|
306
311
|
definition = get_pipe_query(pipe)
|
307
|
-
return (
|
308
|
-
|
309
|
-
if pipe.connector.flavor not in ('mysql', 'mariadb')
|
310
|
-
else f"SELECT * FROM (\n{definition}\n) AS {def_name}"
|
311
|
-
)
|
312
|
+
return format_cte_subquery(definition, flavor, 'definition')
|
313
|
+
|
312
314
|
|
313
315
|
def _join_fetch_query(
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
316
|
+
pipe: mrsm.Pipe,
|
317
|
+
flavor: str,
|
318
|
+
debug: bool = False,
|
319
|
+
new_ids: bool = True,
|
320
|
+
**kw
|
321
|
+
) -> str:
|
319
322
|
"""Build a fetch query based on the datetime and ID indices."""
|
320
323
|
if not pipe.exists(debug=debug):
|
321
|
-
return _simple_fetch_query(pipe, debug=debug, **kw)
|
324
|
+
return _simple_fetch_query(pipe, flavor, debug=debug, **kw)
|
322
325
|
|
323
326
|
from meerschaum.utils.sql import sql_item_name, dateadd_str
|
324
327
|
pipe_instance_name = sql_item_name(
|
@@ -350,7 +353,8 @@ def _join_fetch_query(
|
|
350
353
|
"""
|
351
354
|
sync_times = pipe.instance_connector.read(sync_times_query, debug=debug, silent=False)
|
352
355
|
if sync_times is None:
|
353
|
-
return _simple_fetch_query(pipe, debug=debug, **kw)
|
356
|
+
return _simple_fetch_query(pipe, flavor, debug=debug, **kw)
|
357
|
+
|
354
358
|
_sync_times_q = f",\n{sync_times_remote_name} AS ("
|
355
359
|
for _id, _st in sync_times.itertuples(index=False):
|
356
360
|
_sync_times_q += (
|
@@ -2096,7 +2096,7 @@ def get_pipe_rowcount(
|
|
2096
2096
|
An `int` for the number of rows if the `pipe` exists, otherwise `None`.
|
2097
2097
|
|
2098
2098
|
"""
|
2099
|
-
from meerschaum.utils.sql import dateadd_str, sql_item_name,
|
2099
|
+
from meerschaum.utils.sql import dateadd_str, sql_item_name, wrap_query_with_cte
|
2100
2100
|
from meerschaum.connectors.sql._fetch import get_pipe_query
|
2101
2101
|
if remote:
|
2102
2102
|
msg = f"'fetch:definition' must be an attribute of {pipe} to get a remote rowcount."
|
@@ -2175,20 +2175,10 @@ def get_pipe_rowcount(
|
|
2175
2175
|
if not remote
|
2176
2176
|
else get_pipe_query(pipe)
|
2177
2177
|
)
|
2178
|
-
|
2179
|
-
|
2180
|
-
WITH src AS ({src})
|
2181
|
-
SELECT COUNT(*)
|
2182
|
-
FROM src
|
2183
|
-
"""
|
2184
|
-
) if self.flavor not in ('mysql', 'mariadb') else (
|
2185
|
-
f"""
|
2186
|
-
SELECT COUNT(*)
|
2187
|
-
FROM ({src}) AS src
|
2188
|
-
"""
|
2189
|
-
)
|
2178
|
+
parent_query = f"SELECT COUNT(*)\nFROM {sql_item_name('src', self.flavor)}"
|
2179
|
+
query = wrap_query_with_cte(src, parent_query, self.flavor)
|
2190
2180
|
if begin is not None or end is not None:
|
2191
|
-
query += "
|
2181
|
+
query += "\nWHERE"
|
2192
2182
|
if begin is not None:
|
2193
2183
|
query += f"""
|
2194
2184
|
{dt} >= {dateadd_str(self.flavor, datepart='minute', number=0, begin=begin)}
|
@@ -2330,10 +2320,10 @@ def clear_pipe(
|
|
2330
2320
|
|
2331
2321
|
|
2332
2322
|
def get_pipe_table(
|
2333
|
-
|
2334
|
-
|
2335
|
-
|
2336
|
-
|
2323
|
+
self,
|
2324
|
+
pipe: mrsm.Pipe,
|
2325
|
+
debug: bool = False,
|
2326
|
+
) -> Union['sqlalchemy.Table', None]:
|
2337
2327
|
"""
|
2338
2328
|
Return the `sqlalchemy.Table` object for a `mrsm.Pipe`.
|
2339
2329
|
|
@@ -2352,18 +2342,18 @@ def get_pipe_table(
|
|
2352
2342
|
return None
|
2353
2343
|
return get_sqlalchemy_table(
|
2354
2344
|
pipe.target,
|
2355
|
-
connector
|
2356
|
-
schema
|
2357
|
-
debug
|
2358
|
-
refresh
|
2345
|
+
connector=self,
|
2346
|
+
schema=self.get_pipe_schema(pipe),
|
2347
|
+
debug=debug,
|
2348
|
+
refresh=True,
|
2359
2349
|
)
|
2360
2350
|
|
2361
2351
|
|
2362
2352
|
def get_pipe_columns_types(
|
2363
|
-
|
2364
|
-
|
2365
|
-
|
2366
|
-
|
2353
|
+
self,
|
2354
|
+
pipe: mrsm.Pipe,
|
2355
|
+
debug: bool = False,
|
2356
|
+
) -> Dict[str, str]:
|
2367
2357
|
"""
|
2368
2358
|
Get the pipe's columns and types.
|
2369
2359
|
|
@@ -2394,8 +2384,8 @@ def get_pipe_columns_types(
|
|
2394
2384
|
return get_table_cols_types(
|
2395
2385
|
pipe.target,
|
2396
2386
|
self,
|
2397
|
-
flavor
|
2398
|
-
schema
|
2387
|
+
flavor=self.flavor,
|
2388
|
+
schema=self.get_pipe_schema(pipe),
|
2399
2389
|
)
|
2400
2390
|
|
2401
2391
|
table_columns = {}
|
@@ -2448,6 +2438,7 @@ def get_add_columns_queries(
|
|
2448
2438
|
from meerschaum.utils.sql import (
|
2449
2439
|
sql_item_name,
|
2450
2440
|
SINGLE_ALTER_TABLE_FLAVORS,
|
2441
|
+
get_table_cols_types,
|
2451
2442
|
)
|
2452
2443
|
from meerschaum.utils.dtypes.sql import (
|
2453
2444
|
get_pd_type_from_db_type,
|
@@ -2480,6 +2471,14 @@ def get_add_columns_queries(
|
|
2480
2471
|
db_cols_types = {
|
2481
2472
|
col: get_pd_type_from_db_type(str(typ.type))
|
2482
2473
|
for col, typ in table_obj.columns.items()
|
2474
|
+
} if table_obj is not None else {
|
2475
|
+
col: get_pd_type_from_db_type(typ)
|
2476
|
+
for col, typ in get_table_cols_types(
|
2477
|
+
pipe.target,
|
2478
|
+
self,
|
2479
|
+
schema=self.get_pipe_schema(pipe),
|
2480
|
+
debug=debug,
|
2481
|
+
).items()
|
2483
2482
|
}
|
2484
2483
|
new_cols = set(df_cols_types) - set(db_cols_types)
|
2485
2484
|
if not new_cols:
|
@@ -2552,7 +2551,7 @@ def get_alter_columns_queries(
|
|
2552
2551
|
"""
|
2553
2552
|
if not pipe.exists(debug=debug):
|
2554
2553
|
return []
|
2555
|
-
from meerschaum.utils.sql import sql_item_name, DROP_IF_EXISTS_FLAVORS
|
2554
|
+
from meerschaum.utils.sql import sql_item_name, DROP_IF_EXISTS_FLAVORS, get_table_cols_types
|
2556
2555
|
from meerschaum.utils.dataframe import get_numeric_cols
|
2557
2556
|
from meerschaum.utils.dtypes import are_dtypes_equal
|
2558
2557
|
from meerschaum.utils.dtypes.sql import (
|
@@ -2583,6 +2582,14 @@ def get_alter_columns_queries(
|
|
2583
2582
|
db_cols_types = {
|
2584
2583
|
col: get_pd_type_from_db_type(str(typ.type))
|
2585
2584
|
for col, typ in table_obj.columns.items()
|
2585
|
+
} if table_obj is not None else {
|
2586
|
+
col: get_pd_type_from_db_type(typ)
|
2587
|
+
for col, typ in get_table_cols_types(
|
2588
|
+
pipe.target,
|
2589
|
+
self,
|
2590
|
+
schema=self.get_pipe_schema(pipe),
|
2591
|
+
debug=debug,
|
2592
|
+
).items()
|
2586
2593
|
}
|
2587
2594
|
pipe_bool_cols = [col for col, typ in pipe.dtypes.items() if are_dtypes_equal(str(typ), 'bool')]
|
2588
2595
|
pd_db_df_aliases = {
|