MCPcopy Create free account
hub / github.com/apache/arrow / _perform_join_asof

Function _perform_join_asof

python/pyarrow/acero.py:264–352  ·  view source on GitHub ↗

Perform asof join of two tables or datasets. The result will be an output table with the result of the join operation Parameters ---------- left_operand : Table or Dataset The left operand for the join operation. left_on : str The left key (or keys) on whic

(left_operand, left_on, left_by,
                       right_operand, right_on, right_by,
                       tolerance, use_threads=True,
                       output_type=Table)

Source from the content-addressed store, hash-verified

262
263
264def _perform_join_asof(left_operand, left_on, left_by,
265 right_operand, right_on, right_by,
266 tolerance, use_threads=True,
267 output_type=Table):
268 """
269 Perform asof join of two tables or datasets.
270
271 The result will be an output table with the result of the join operation
272
273 Parameters
274 ----------
275 left_operand : Table or Dataset
276 The left operand for the join operation.
277 left_on : str
278 The left key (or keys) on which the join operation should be performed.
279 left_by: str or list[str]
280 The left key (or keys) on which the join operation should be performed.
281 right_operand : Table or Dataset
282 The right operand for the join operation.
283 right_on : str or list[str]
284 The right key (or keys) on which the join operation should be performed.
285 right_by: str or list[str]
286 The right key (or keys) on which the join operation should be performed.
287 tolerance : int
288 The tolerance to use for the asof join. The tolerance is interpreted in
289 the same units as the "on" key.
290 output_type: Table or InMemoryDataset
291 The output type for the exec plan result.
292
293 Returns
294 -------
295 result_table : Table or InMemoryDataset
296 """
297 if not isinstance(left_operand, (Table, ds.Dataset)):
298 raise TypeError(f"Expected Table or Dataset, got {type(left_operand)}")
299 if not isinstance(right_operand, (Table, ds.Dataset)):
300 raise TypeError(f"Expected Table or Dataset, got {type(right_operand)}")
301
302 if not isinstance(left_by, (tuple, list)):
303 left_by = [left_by]
304 if not isinstance(right_by, (tuple, list)):
305 right_by = [right_by]
306
307 # AsofJoin does not return on or by columns for right_operand.
308 right_columns = [
309 col for col in right_operand.schema.names
310 if col not in [right_on] + right_by
311 ]
312 columns_collisions = set(left_operand.schema.names) & set(right_columns)
313 if columns_collisions:
314 raise ValueError(
315 f"Columns {columns_collisions} present in both tables. "
316 "AsofJoin does not support column collisions."
317 )
318
319 # Add the join node to the execplan
320 if isinstance(left_operand, ds.Dataset):
321 left_source = _dataset_to_decl(

Callers

nothing calls this directly

Calls 7

_dataset_to_declFunction · 0.85
TableSourceNodeOptionsFunction · 0.85
InMemoryDatasetMethod · 0.80
TypeErrorFunction · 0.50
typeEnum · 0.50
DeclarationClass · 0.50
to_tableMethod · 0.45

Tested by

no test coverage detected