(self, expression: expr.ColumnExpression)
| 246 | return result |
| 247 | |
| 248 | def _validate_expression(self, expression: expr.ColumnExpression): |
| 249 | for dep in expression._dependencies_above_reducer(): |
| 250 | if ( |
| 251 | not isinstance(dep._table, thisclass.ThisMetaclass) # allow for ix |
| 252 | and dep.to_column_expression()._to_original()._to_internal() |
| 253 | not in self._grouping_columns |
| 254 | ): |
| 255 | raise ValueError( |
| 256 | f"You cannot use {dep.to_column_expression()} in this reduce statement.\n" |
| 257 | + f"Make sure that {dep.to_column_expression()} is used in a groupby or wrap it with a reducer, " |
| 258 | + f"e.g. pw.reducers.count({dep.to_column_expression()})" |
| 259 | ) |
| 260 | |
| 261 | for dep in expression._dependencies_below_reducer(): |
| 262 | if ( |
| 263 | self._joinable_to_group._universe |
| 264 | != dep.to_column_expression()._column.universe |
| 265 | ): |
| 266 | raise ValueError( |
| 267 | f"You cannot use {dep.to_column_expression()} in this context." |
| 268 | + " Its universe is different than the universe of the table the method" |
| 269 | + " was called on. You can use <table1>.with_universe_of(<table2>)" |
| 270 | + " to assign universe of <table2> to <table1> if you're sure their" |
| 271 | + " sets of keys are equal." |
| 272 | ) |
| 273 | |
| 274 | @lru_cache |
| 275 | def _operator_dependencies(self) -> StableSet[table.Table]: |
no test coverage detected