MindsDB 25.7.3.0__py3-none-any.whl → 25.8.2.0__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 MindsDB might be problematic. Click here for more details.
- mindsdb/__about__.py +1 -1
- mindsdb/__main__.py +11 -1
- mindsdb/api/a2a/common/server/server.py +16 -6
- mindsdb/api/executor/command_executor.py +215 -150
- mindsdb/api/executor/datahub/datanodes/project_datanode.py +14 -3
- mindsdb/api/executor/planner/plan_join.py +3 -0
- mindsdb/api/executor/planner/plan_join_ts.py +117 -100
- mindsdb/api/executor/planner/query_planner.py +1 -0
- mindsdb/api/executor/sql_query/steps/apply_predictor_step.py +54 -85
- mindsdb/api/executor/sql_query/steps/fetch_dataframe.py +21 -24
- mindsdb/api/executor/sql_query/steps/fetch_dataframe_partition.py +9 -3
- mindsdb/api/executor/sql_query/steps/subselect_step.py +11 -8
- mindsdb/api/executor/utilities/mysql_to_duckdb_functions.py +264 -0
- mindsdb/api/executor/utilities/sql.py +30 -0
- mindsdb/api/http/initialize.py +18 -44
- mindsdb/api/http/namespaces/agents.py +23 -20
- mindsdb/api/http/namespaces/chatbots.py +83 -120
- mindsdb/api/http/namespaces/file.py +1 -1
- mindsdb/api/http/namespaces/jobs.py +38 -60
- mindsdb/api/http/namespaces/tree.py +69 -61
- mindsdb/api/http/namespaces/views.py +56 -72
- mindsdb/api/mcp/start.py +2 -0
- mindsdb/api/mysql/mysql_proxy/utilities/dump.py +3 -2
- mindsdb/integrations/handlers/autogluon_handler/requirements.txt +1 -1
- mindsdb/integrations/handlers/autosklearn_handler/requirements.txt +1 -1
- mindsdb/integrations/handlers/bigquery_handler/bigquery_handler.py +25 -5
- mindsdb/integrations/handlers/chromadb_handler/chromadb_handler.py +3 -3
- mindsdb/integrations/handlers/db2_handler/db2_handler.py +19 -23
- mindsdb/integrations/handlers/flaml_handler/requirements.txt +1 -1
- mindsdb/integrations/handlers/gong_handler/__about__.py +2 -0
- mindsdb/integrations/handlers/gong_handler/__init__.py +30 -0
- mindsdb/integrations/handlers/gong_handler/connection_args.py +37 -0
- mindsdb/integrations/handlers/gong_handler/gong_handler.py +164 -0
- mindsdb/integrations/handlers/gong_handler/gong_tables.py +508 -0
- mindsdb/integrations/handlers/gong_handler/icon.svg +25 -0
- mindsdb/integrations/handlers/gong_handler/test_gong_handler.py +125 -0
- mindsdb/integrations/handlers/google_calendar_handler/google_calendar_tables.py +82 -73
- mindsdb/integrations/handlers/hubspot_handler/requirements.txt +1 -1
- mindsdb/integrations/handlers/huggingface_handler/__init__.py +8 -12
- mindsdb/integrations/handlers/huggingface_handler/finetune.py +203 -223
- mindsdb/integrations/handlers/huggingface_handler/huggingface_handler.py +360 -383
- mindsdb/integrations/handlers/huggingface_handler/requirements.txt +7 -7
- mindsdb/integrations/handlers/huggingface_handler/requirements_cpu.txt +7 -7
- mindsdb/integrations/handlers/huggingface_handler/settings.py +25 -25
- mindsdb/integrations/handlers/langchain_handler/langchain_handler.py +83 -77
- mindsdb/integrations/handlers/lightwood_handler/requirements.txt +4 -4
- mindsdb/integrations/handlers/litellm_handler/litellm_handler.py +5 -2
- mindsdb/integrations/handlers/litellm_handler/settings.py +2 -1
- mindsdb/integrations/handlers/openai_handler/constants.py +11 -30
- mindsdb/integrations/handlers/openai_handler/helpers.py +27 -34
- mindsdb/integrations/handlers/openai_handler/openai_handler.py +14 -12
- mindsdb/integrations/handlers/pgvector_handler/pgvector_handler.py +106 -90
- mindsdb/integrations/handlers/postgres_handler/postgres_handler.py +41 -39
- mindsdb/integrations/handlers/salesforce_handler/constants.py +215 -0
- mindsdb/integrations/handlers/salesforce_handler/salesforce_handler.py +141 -80
- mindsdb/integrations/handlers/salesforce_handler/salesforce_tables.py +0 -1
- mindsdb/integrations/handlers/tpot_handler/requirements.txt +1 -1
- mindsdb/integrations/handlers/web_handler/urlcrawl_helpers.py +32 -17
- mindsdb/integrations/handlers/web_handler/web_handler.py +19 -22
- mindsdb/integrations/libs/llm/config.py +0 -14
- mindsdb/integrations/libs/llm/utils.py +0 -15
- mindsdb/integrations/libs/vectordatabase_handler.py +10 -1
- mindsdb/integrations/utilities/files/file_reader.py +5 -19
- mindsdb/integrations/utilities/handler_utils.py +32 -12
- mindsdb/integrations/utilities/rag/rerankers/base_reranker.py +1 -1
- mindsdb/interfaces/agents/agents_controller.py +246 -149
- mindsdb/interfaces/agents/constants.py +0 -1
- mindsdb/interfaces/agents/langchain_agent.py +11 -6
- mindsdb/interfaces/data_catalog/data_catalog_loader.py +4 -4
- mindsdb/interfaces/database/database.py +38 -13
- mindsdb/interfaces/database/integrations.py +20 -5
- mindsdb/interfaces/database/projects.py +174 -23
- mindsdb/interfaces/database/views.py +86 -60
- mindsdb/interfaces/jobs/jobs_controller.py +103 -110
- mindsdb/interfaces/knowledge_base/controller.py +33 -6
- mindsdb/interfaces/knowledge_base/evaluate.py +2 -1
- mindsdb/interfaces/knowledge_base/executor.py +24 -0
- mindsdb/interfaces/knowledge_base/preprocessing/document_preprocessor.py +6 -10
- mindsdb/interfaces/knowledge_base/preprocessing/text_splitter.py +73 -0
- mindsdb/interfaces/query_context/context_controller.py +111 -145
- mindsdb/interfaces/skills/skills_controller.py +18 -6
- mindsdb/interfaces/storage/db.py +40 -6
- mindsdb/interfaces/variables/variables_controller.py +8 -15
- mindsdb/utilities/config.py +5 -3
- mindsdb/utilities/fs.py +54 -17
- mindsdb/utilities/functions.py +72 -60
- mindsdb/utilities/log.py +38 -6
- mindsdb/utilities/ps.py +7 -7
- {mindsdb-25.7.3.0.dist-info → mindsdb-25.8.2.0.dist-info}/METADATA +282 -268
- {mindsdb-25.7.3.0.dist-info → mindsdb-25.8.2.0.dist-info}/RECORD +94 -92
- mindsdb/integrations/handlers/anyscale_endpoints_handler/__about__.py +0 -9
- mindsdb/integrations/handlers/anyscale_endpoints_handler/__init__.py +0 -20
- mindsdb/integrations/handlers/anyscale_endpoints_handler/anyscale_endpoints_handler.py +0 -290
- mindsdb/integrations/handlers/anyscale_endpoints_handler/creation_args.py +0 -14
- mindsdb/integrations/handlers/anyscale_endpoints_handler/icon.svg +0 -4
- mindsdb/integrations/handlers/anyscale_endpoints_handler/requirements.txt +0 -2
- mindsdb/integrations/handlers/anyscale_endpoints_handler/settings.py +0 -51
- mindsdb/integrations/handlers/anyscale_endpoints_handler/tests/test_anyscale_endpoints_handler.py +0 -212
- /mindsdb/integrations/handlers/{anyscale_endpoints_handler/tests/__init__.py → gong_handler/requirements.txt} +0 -0
- {mindsdb-25.7.3.0.dist-info → mindsdb-25.8.2.0.dist-info}/WHEEL +0 -0
- {mindsdb-25.7.3.0.dist-info → mindsdb-25.8.2.0.dist-info}/licenses/LICENSE +0 -0
- {mindsdb-25.7.3.0.dist-info → mindsdb-25.8.2.0.dist-info}/top_level.txt +0 -0
|
@@ -2,8 +2,15 @@ import copy
|
|
|
2
2
|
|
|
3
3
|
from mindsdb_sql_parser.ast.mindsdb import Latest
|
|
4
4
|
from mindsdb_sql_parser.ast import (
|
|
5
|
-
Select,
|
|
6
|
-
|
|
5
|
+
Select,
|
|
6
|
+
Identifier,
|
|
7
|
+
BetweenOperation,
|
|
8
|
+
Join,
|
|
9
|
+
Star,
|
|
10
|
+
BinaryOperation,
|
|
11
|
+
Constant,
|
|
12
|
+
OrderBy,
|
|
13
|
+
NullConstant,
|
|
7
14
|
)
|
|
8
15
|
|
|
9
16
|
from mindsdb.integrations.utilities.query_traversal import query_traversal
|
|
@@ -11,15 +18,22 @@ from mindsdb.integrations.utilities.query_traversal import query_traversal
|
|
|
11
18
|
from mindsdb.api.executor.planner.exceptions import PlanningException
|
|
12
19
|
from mindsdb.api.executor.planner import utils
|
|
13
20
|
from mindsdb.api.executor.planner.steps import (
|
|
14
|
-
JoinStep,
|
|
15
|
-
|
|
21
|
+
JoinStep,
|
|
22
|
+
LimitOffsetStep,
|
|
23
|
+
MultipleSteps,
|
|
24
|
+
MapReduceStep,
|
|
25
|
+
ApplyTimeseriesPredictorStep,
|
|
26
|
+
)
|
|
27
|
+
from mindsdb.api.executor.planner.ts_utils import (
|
|
28
|
+
validate_ts_where_condition,
|
|
29
|
+
find_time_filter,
|
|
30
|
+
replace_time_filter,
|
|
31
|
+
find_and_remove_time_filter,
|
|
32
|
+
recursively_check_join_identifiers_for_ambiguity,
|
|
16
33
|
)
|
|
17
|
-
from mindsdb.api.executor.planner.ts_utils import validate_ts_where_condition, find_time_filter, replace_time_filter, \
|
|
18
|
-
find_and_remove_time_filter, recursively_check_join_identifiers_for_ambiguity
|
|
19
34
|
|
|
20
35
|
|
|
21
36
|
class PlanJoinTSPredictorQuery:
|
|
22
|
-
|
|
23
37
|
def __init__(self, planner):
|
|
24
38
|
self.planner = planner
|
|
25
39
|
|
|
@@ -62,7 +76,7 @@ class PlanJoinTSPredictorQuery:
|
|
|
62
76
|
# add latest to query.where
|
|
63
77
|
for cond in moved_conditions:
|
|
64
78
|
if query.where is not None:
|
|
65
|
-
query.where = BinaryOperation(
|
|
79
|
+
query.where = BinaryOperation("and", args=[query.where, cond])
|
|
66
80
|
else:
|
|
67
81
|
query.where = cond
|
|
68
82
|
|
|
@@ -71,18 +85,17 @@ class PlanJoinTSPredictorQuery:
|
|
|
71
85
|
if len(node.parts) == 1:
|
|
72
86
|
# add table alias to field
|
|
73
87
|
node.parts = table_alias + node.parts
|
|
88
|
+
node.is_quoted = [False] + node.is_quoted
|
|
74
89
|
|
|
75
90
|
query_traversal(query.where, add_aliases)
|
|
76
91
|
|
|
77
92
|
if isinstance(query.from_table, Identifier):
|
|
78
93
|
# DBT workaround: allow use tables without integration.
|
|
79
94
|
# if table.part[0] not in integration - take integration name from create table command
|
|
80
|
-
if
|
|
81
|
-
integration is not None
|
|
82
|
-
and query.from_table.parts[0] not in self.planner.databases
|
|
83
|
-
):
|
|
95
|
+
if integration is not None and query.from_table.parts[0] not in self.planner.databases:
|
|
84
96
|
# add integration name to table
|
|
85
97
|
query.from_table.parts.insert(0, integration)
|
|
98
|
+
query.from_table.is_quoted.insert(0, False)
|
|
86
99
|
|
|
87
100
|
join_left = join_left.from_table
|
|
88
101
|
|
|
@@ -103,10 +116,7 @@ class PlanJoinTSPredictorQuery:
|
|
|
103
116
|
return aliased_fields
|
|
104
117
|
|
|
105
118
|
def plan_fetch_timeseries_partitions(self, query, table, predictor_group_by_names):
|
|
106
|
-
targets = [
|
|
107
|
-
Identifier(column)
|
|
108
|
-
for column in predictor_group_by_names
|
|
109
|
-
]
|
|
119
|
+
targets = [Identifier(column) for column in predictor_group_by_names]
|
|
110
120
|
|
|
111
121
|
query = Select(
|
|
112
122
|
distinct=True,
|
|
@@ -133,7 +143,7 @@ class PlanJoinTSPredictorQuery:
|
|
|
133
143
|
|
|
134
144
|
if self.planner.is_predictor(join_left):
|
|
135
145
|
# in the left is also predictor
|
|
136
|
-
raise PlanningException(f
|
|
146
|
+
raise PlanningException(f"Can't join two predictors {join_left} and {join_left}")
|
|
137
147
|
|
|
138
148
|
orig_query = query
|
|
139
149
|
# dbt query?
|
|
@@ -155,16 +165,16 @@ class PlanJoinTSPredictorQuery:
|
|
|
155
165
|
# add join
|
|
156
166
|
# Update reference
|
|
157
167
|
|
|
158
|
-
left = Identifier(predictor_steps[
|
|
159
|
-
right = Identifier(predictor_steps[
|
|
168
|
+
left = Identifier(predictor_steps["predictor"].result.ref_name)
|
|
169
|
+
right = Identifier(predictor_steps["data"].result.ref_name)
|
|
160
170
|
|
|
161
171
|
if not predictor_is_left:
|
|
162
172
|
# swap join
|
|
163
173
|
left, right = right, left
|
|
164
174
|
new_join = Join(left=left, right=right, join_type=join.join_type)
|
|
165
175
|
|
|
166
|
-
left = predictor_steps[
|
|
167
|
-
right = predictor_steps[
|
|
176
|
+
left = predictor_steps["predictor"].result
|
|
177
|
+
right = predictor_steps["data"].result
|
|
168
178
|
if not predictor_is_left:
|
|
169
179
|
# swap join
|
|
170
180
|
left, right = right, left
|
|
@@ -172,33 +182,33 @@ class PlanJoinTSPredictorQuery:
|
|
|
172
182
|
last_step = self.planner.plan.add_step(JoinStep(left=left, right=right, query=new_join))
|
|
173
183
|
|
|
174
184
|
# limit from timeseries
|
|
175
|
-
if predictor_steps.get(
|
|
185
|
+
if predictor_steps.get("saved_limit"):
|
|
176
186
|
last_step = self.planner.plan.add_step(
|
|
177
|
-
LimitOffsetStep(dataframe=last_step.result, limit=predictor_steps[
|
|
187
|
+
LimitOffsetStep(dataframe=last_step.result, limit=predictor_steps["saved_limit"])
|
|
178
188
|
)
|
|
179
189
|
|
|
180
190
|
return self.planner.plan_project(orig_query, last_step.result)
|
|
181
191
|
|
|
182
192
|
def plan_timeseries_predictor(self, query, table, predictor_namespace, predictor):
|
|
183
|
-
|
|
184
193
|
predictor_metadata = self.planner.get_predictor(predictor)
|
|
185
194
|
|
|
186
|
-
predictor_time_column_name = predictor_metadata[
|
|
187
|
-
predictor_group_by_names = predictor_metadata[
|
|
195
|
+
predictor_time_column_name = predictor_metadata["order_by_column"]
|
|
196
|
+
predictor_group_by_names = predictor_metadata["group_by_columns"]
|
|
188
197
|
if predictor_group_by_names is None:
|
|
189
198
|
predictor_group_by_names = []
|
|
190
|
-
predictor_window = predictor_metadata[
|
|
199
|
+
predictor_window = predictor_metadata["window"]
|
|
191
200
|
|
|
192
201
|
if query.order_by:
|
|
193
202
|
raise PlanningException(
|
|
194
|
-
f
|
|
203
|
+
f"Can't provide ORDER BY to time series predictor, it will be taken from predictor settings. Found: {query.order_by}"
|
|
204
|
+
)
|
|
195
205
|
|
|
196
206
|
saved_limit = None
|
|
197
207
|
if query.limit is not None:
|
|
198
208
|
saved_limit = query.limit.value
|
|
199
209
|
|
|
200
210
|
if query.group_by or query.having or query.offset:
|
|
201
|
-
raise PlanningException(f
|
|
211
|
+
raise PlanningException(f"Unsupported query to timeseries predictor: {str(query)}")
|
|
202
212
|
|
|
203
213
|
allowed_columns = [predictor_time_column_name.lower()]
|
|
204
214
|
if len(predictor_group_by_names) > 0:
|
|
@@ -212,21 +222,17 @@ class PlanJoinTSPredictorQuery:
|
|
|
212
222
|
|
|
213
223
|
time_filter = find_time_filter(preparation_where, time_column_name=predictor_time_column_name)
|
|
214
224
|
|
|
215
|
-
order_by = [OrderBy(Identifier(parts=[predictor_time_column_name]), direction=
|
|
225
|
+
order_by = [OrderBy(Identifier(parts=[predictor_time_column_name]), direction="DESC")]
|
|
216
226
|
|
|
217
227
|
query_modifiers = query.modifiers
|
|
218
228
|
|
|
219
229
|
# add {order_by_field} is not null
|
|
220
230
|
def add_order_not_null(condition):
|
|
221
|
-
order_field_not_null = BinaryOperation(
|
|
222
|
-
Identifier(parts=[predictor_time_column_name]),
|
|
223
|
-
|
|
224
|
-
])
|
|
231
|
+
order_field_not_null = BinaryOperation(
|
|
232
|
+
op="is not", args=[Identifier(parts=[predictor_time_column_name]), NullConstant()]
|
|
233
|
+
)
|
|
225
234
|
if condition is not None:
|
|
226
|
-
condition = BinaryOperation(op=
|
|
227
|
-
condition,
|
|
228
|
-
order_field_not_null
|
|
229
|
-
])
|
|
235
|
+
condition = BinaryOperation(op="and", args=[condition, order_field_not_null])
|
|
230
236
|
else:
|
|
231
237
|
condition = order_field_not_null
|
|
232
238
|
return condition
|
|
@@ -237,7 +243,7 @@ class PlanJoinTSPredictorQuery:
|
|
|
237
243
|
# Obtain integration selects
|
|
238
244
|
if isinstance(time_filter, BetweenOperation):
|
|
239
245
|
between_from = time_filter.args[1]
|
|
240
|
-
preparation_time_filter = BinaryOperation(
|
|
246
|
+
preparation_time_filter = BinaryOperation("<", args=[Identifier(predictor_time_column_name), between_from])
|
|
241
247
|
preparation_where2 = replace_time_filter(preparation_where2, time_filter, preparation_time_filter)
|
|
242
248
|
integration_select_1 = Select(
|
|
243
249
|
targets=[Star()],
|
|
@@ -245,81 +251,86 @@ class PlanJoinTSPredictorQuery:
|
|
|
245
251
|
where=add_order_not_null(preparation_where2),
|
|
246
252
|
modifiers=query_modifiers,
|
|
247
253
|
order_by=order_by,
|
|
248
|
-
limit=Constant(predictor_window)
|
|
254
|
+
limit=Constant(predictor_window),
|
|
249
255
|
)
|
|
250
256
|
|
|
251
|
-
integration_select_2 = Select(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
257
|
+
integration_select_2 = Select(
|
|
258
|
+
targets=[Star()],
|
|
259
|
+
from_table=table,
|
|
260
|
+
where=preparation_where,
|
|
261
|
+
modifiers=query_modifiers,
|
|
262
|
+
order_by=order_by,
|
|
263
|
+
)
|
|
256
264
|
|
|
257
265
|
integration_selects = [integration_select_1, integration_select_2]
|
|
258
|
-
elif isinstance(time_filter, BinaryOperation) and time_filter.op ==
|
|
259
|
-
integration_select = Select(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
+
elif isinstance(time_filter, BinaryOperation) and time_filter.op == ">" and time_filter.args[1] == Latest():
|
|
267
|
+
integration_select = Select(
|
|
268
|
+
targets=[Star()],
|
|
269
|
+
from_table=table,
|
|
270
|
+
where=preparation_where,
|
|
271
|
+
modifiers=query_modifiers,
|
|
272
|
+
order_by=order_by,
|
|
273
|
+
limit=Constant(predictor_window),
|
|
274
|
+
)
|
|
266
275
|
integration_select.where = find_and_remove_time_filter(integration_select.where, time_filter)
|
|
267
276
|
integration_selects = [integration_select]
|
|
268
|
-
elif isinstance(time_filter, BinaryOperation) and time_filter.op ==
|
|
269
|
-
integration_select = Select(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
277
|
+
elif isinstance(time_filter, BinaryOperation) and time_filter.op == "=":
|
|
278
|
+
integration_select = Select(
|
|
279
|
+
targets=[Star()],
|
|
280
|
+
from_table=table,
|
|
281
|
+
where=preparation_where,
|
|
282
|
+
modifiers=query_modifiers,
|
|
283
|
+
order_by=order_by,
|
|
284
|
+
limit=Constant(predictor_window),
|
|
285
|
+
)
|
|
276
286
|
|
|
277
287
|
if type(time_filter.args[1]) is Latest:
|
|
278
288
|
integration_select.where = find_and_remove_time_filter(integration_select.where, time_filter)
|
|
279
289
|
else:
|
|
280
290
|
time_filter_date = time_filter.args[1]
|
|
281
291
|
preparation_time_filter = BinaryOperation(
|
|
282
|
-
|
|
283
|
-
args=[
|
|
284
|
-
Identifier(predictor_time_column_name),
|
|
285
|
-
time_filter_date
|
|
286
|
-
]
|
|
292
|
+
"<=", args=[Identifier(predictor_time_column_name), time_filter_date]
|
|
287
293
|
)
|
|
288
294
|
integration_select.where = add_order_not_null(
|
|
289
|
-
replace_time_filter(
|
|
290
|
-
preparation_where2, time_filter, preparation_time_filter
|
|
291
|
-
)
|
|
295
|
+
replace_time_filter(preparation_where2, time_filter, preparation_time_filter)
|
|
292
296
|
)
|
|
293
|
-
time_filter.op =
|
|
297
|
+
time_filter.op = ">"
|
|
294
298
|
|
|
295
299
|
integration_selects = [integration_select]
|
|
296
|
-
elif isinstance(time_filter, BinaryOperation) and time_filter.op in (
|
|
300
|
+
elif isinstance(time_filter, BinaryOperation) and time_filter.op in (">", ">="):
|
|
297
301
|
time_filter_date = time_filter.args[1]
|
|
298
|
-
preparation_time_filter_op = {
|
|
302
|
+
preparation_time_filter_op = {">": "<=", ">=": "<"}[time_filter.op]
|
|
299
303
|
|
|
300
|
-
preparation_time_filter = BinaryOperation(
|
|
304
|
+
preparation_time_filter = BinaryOperation(
|
|
305
|
+
preparation_time_filter_op, args=[Identifier(predictor_time_column_name), time_filter_date]
|
|
306
|
+
)
|
|
301
307
|
preparation_where2 = replace_time_filter(preparation_where2, time_filter, preparation_time_filter)
|
|
302
|
-
integration_select_1 = Select(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
308
|
+
integration_select_1 = Select(
|
|
309
|
+
targets=[Star()],
|
|
310
|
+
from_table=table,
|
|
311
|
+
where=add_order_not_null(preparation_where2),
|
|
312
|
+
modifiers=query_modifiers,
|
|
313
|
+
order_by=order_by,
|
|
314
|
+
limit=Constant(predictor_window),
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
integration_select_2 = Select(
|
|
318
|
+
targets=[Star()],
|
|
319
|
+
from_table=table,
|
|
320
|
+
where=preparation_where,
|
|
321
|
+
modifiers=query_modifiers,
|
|
322
|
+
order_by=order_by,
|
|
323
|
+
)
|
|
314
324
|
|
|
315
325
|
integration_selects = [integration_select_1, integration_select_2]
|
|
316
326
|
else:
|
|
317
|
-
integration_select = Select(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
327
|
+
integration_select = Select(
|
|
328
|
+
targets=[Star()],
|
|
329
|
+
from_table=table,
|
|
330
|
+
where=preparation_where,
|
|
331
|
+
modifiers=query_modifiers,
|
|
332
|
+
order_by=order_by,
|
|
333
|
+
)
|
|
323
334
|
integration_selects = [integration_select]
|
|
324
335
|
|
|
325
336
|
if len(predictor_group_by_names) == 0:
|
|
@@ -329,7 +340,8 @@ class PlanJoinTSPredictorQuery:
|
|
|
329
340
|
select_partition_step = self.planner.get_integration_select_step(integration_selects[0])
|
|
330
341
|
else:
|
|
331
342
|
select_partition_step = MultipleSteps(
|
|
332
|
-
steps=[self.planner.get_integration_select_step(s) for s in integration_selects], reduce=
|
|
343
|
+
steps=[self.planner.get_integration_select_step(s) for s in integration_selects], reduce="union"
|
|
344
|
+
)
|
|
333
345
|
|
|
334
346
|
# fetch data step
|
|
335
347
|
data_step = self.planner.plan.add_step(select_partition_step)
|
|
@@ -338,13 +350,13 @@ class PlanJoinTSPredictorQuery:
|
|
|
338
350
|
for integration_select in integration_selects:
|
|
339
351
|
condition = integration_select.where
|
|
340
352
|
for num, column in enumerate(predictor_group_by_names):
|
|
341
|
-
cond = BinaryOperation(
|
|
353
|
+
cond = BinaryOperation("=", args=[Identifier(column), Constant(f"$var[{column}]")])
|
|
342
354
|
|
|
343
355
|
# join to main condition
|
|
344
356
|
if condition is None:
|
|
345
357
|
condition = cond
|
|
346
358
|
else:
|
|
347
|
-
condition = BinaryOperation(
|
|
359
|
+
condition = BinaryOperation("and", args=[condition, cond])
|
|
348
360
|
|
|
349
361
|
integration_select.where = condition
|
|
350
362
|
# one or multistep
|
|
@@ -352,14 +364,19 @@ class PlanJoinTSPredictorQuery:
|
|
|
352
364
|
select_partition_step = self.planner.get_integration_select_step(integration_selects[0])
|
|
353
365
|
else:
|
|
354
366
|
select_partition_step = MultipleSteps(
|
|
355
|
-
steps=[self.planner.get_integration_select_step(s) for s in integration_selects], reduce=
|
|
367
|
+
steps=[self.planner.get_integration_select_step(s) for s in integration_selects], reduce="union"
|
|
368
|
+
)
|
|
356
369
|
|
|
357
370
|
# get groping values
|
|
358
371
|
no_time_filter_query.where = find_and_remove_time_filter(no_time_filter_query.where, time_filter)
|
|
359
|
-
select_partitions_step = self.plan_fetch_timeseries_partitions(
|
|
372
|
+
select_partitions_step = self.plan_fetch_timeseries_partitions(
|
|
373
|
+
no_time_filter_query, table, predictor_group_by_names
|
|
374
|
+
)
|
|
360
375
|
|
|
361
376
|
# sub-query by every grouping value
|
|
362
|
-
map_reduce_step = self.planner.plan.add_step(
|
|
377
|
+
map_reduce_step = self.planner.plan.add_step(
|
|
378
|
+
MapReduceStep(values=select_partitions_step.result, reduce="union", step=select_partition_step)
|
|
379
|
+
)
|
|
363
380
|
data_step = map_reduce_step
|
|
364
381
|
|
|
365
382
|
predictor_identifier = utils.get_predictor_name_identifier(predictor)
|
|
@@ -378,7 +395,7 @@ class PlanJoinTSPredictorQuery:
|
|
|
378
395
|
)
|
|
379
396
|
|
|
380
397
|
return {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
398
|
+
"predictor": predictor_step,
|
|
399
|
+
"data": data_step,
|
|
400
|
+
"saved_limit": saved_limit,
|
|
384
401
|
}
|