restrict_by.py
Mixin to allow restriction by ancestor or descendant fields.
RestrictByMixin
¶
Bases: BaseMixin
Mixin to allow restriction by ancestor or descendant fields.
Source code in src/spyglass/utils/mixins/restrict_by.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
ban_search_table(table)
¶
unban_search_table(table)
¶
see_banned_tables()
¶
restrict_by(restriction=True, direction='up', return_graph=False, verbose=False, **kwargs)
¶
Restrict self based on up/downstream table.
If fails to restrict table, the shortest path may not have been correct. If there's a different path that should be taken, ban unwanted tables.
my_table = MyTable() # must be instantced my_table.ban_search_table(UnwantedTable1) my_table.ban_search_table([UnwantedTable2, UnwantedTable3]) my_table.unban_search_table(UnwantedTable3) my_table.see_banned_tables()
my_table << my_restriction
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
restriction
|
str
|
Restriction to apply to the some table up/downstream of self. |
True
|
direction
|
str
|
Direction to search for valid restriction. Default 'up'. |
'up'
|
return_graph
|
bool
|
If True, return FindKeyGraph object. Default False, returns restricted version of present table. |
False
|
verbose
|
bool
|
If True, print verbose output. Default False. |
False
|
Returns:
| Type | Description |
|---|---|
Union[QueryExpression, TableChain]
|
Restricted version of present table or TableChain object. If return_graph, use all_ft attribute to see all tables in cascade. |
Source code in src/spyglass/utils/mixins/restrict_by.py
__lshift__(restriction)
¶
Restriction by upstream operator e.g. q1 << q2.
Returns:
| Type | Description |
|---|---|
QueryExpression
|
A restricted copy of the query expression using the nearest upstream table for which the restriction is valid. |
Source code in src/spyglass/utils/mixins/restrict_by.py
__rshift__(restriction)
¶
Restriction by downstream operator e.g. q1 >> q2.
Returns:
| Type | Description |
|---|---|
QueryExpression
|
A restricted copy of the query expression using the nearest upstream table for which the restriction is valid. |