cycquery.ops.JoinΒΆ
- class Join(join_table, on=None, on_to_type=None, cond=None, table_cols=None, join_table_cols=None, isouter=False)[source]ΒΆ
Bases:
QueryOp
Join a table with another table.
- Parameters:
join_table (
Union
[Select
,Subquery
,Table
,DBTable
]) β Table on which to join.on (
Union
[str
,List
[str
],Tuple
[str
],List
[Tuple
[str
,str
]],None
]) β A list of strings or tuples representing columns on which to join. Strings represent columns of same name in both tables. A tuple of style (table_col, join_table_col) is used to join on columns of different names. Suggested to specify this parameter as opposed to cond.on_to_type (
Union
[type
,List
[type
],None
]) β A list of types to which to convert the on columns before joining. Useful when two columns have the same values but in different format, e.g., strings of int.cond (
Optional
[BinaryExpression
]) β Condition on which to join to tables.table_cols (
Union
[str
,List
[str
],None
]) β Filters to keep only these columns from the table.join_table_cols (
Union
[str
,List
[str
],None
]) β Filters to keep only these columns from the join_table.isouter (
Optional
[bool
]) β Flag to say if the join is a left outer join.
Examples
>>> Join(table2, on=["col1", ("col2", "col3")], on_to_type=[int, str])(table1) >>> Join(table2, table_cols=["col1", "col2"])(table1) >>> Join(table2, join_table_cols=["col1", "col2"])(table1)
Warning
If neither on nor cond parameters are specified, an expensive Cartesian product is performed.
Methods