Returns updated table with a forced schema on it.
(self, schema: type[Schema])
| 2212 | @contextualized_operator |
| 2213 | @check_arg_types |
| 2214 | def _with_schema(self, schema: type[Schema]) -> Table: |
| 2215 | """Returns updated table with a forced schema on it.""" |
| 2216 | if schema.keys() != self.schema.keys(): |
| 2217 | raise ValueError( |
| 2218 | "Table.with_schema() argument has to have the same column names as in the table." |
| 2219 | ) |
| 2220 | context = clmn.SetSchemaContext( |
| 2221 | _id_column=self._id_column, |
| 2222 | _new_properties={ |
| 2223 | self[name]._to_internal(): schema.column_properties(name) |
| 2224 | for name in self.column_names() |
| 2225 | }, |
| 2226 | _id_column_props=schema.__universe_properties__, |
| 2227 | ) |
| 2228 | return self._table_with_context(context) |
| 2229 | |
| 2230 | @trace_user_frame |
| 2231 | @check_arg_types |
no test coverage detected