Uh oh!
There was an error while loading. Please reload this page.
Fix deepcopy of primitive types - #857
Conversation
0aba3ac to
dc42e88Comparedc42e88 to
a68add0Compare
sungwy
left a comment
There was a problem hiding this comment.
This is really cool 🔥 - thank you for putting in this bug fix so quickly!
This is a nit: I think we could add a test to test_metadata.py to deepcopy a TableMetadata object and ensure that the output is equal to the original one with a Schema representation that contains a mix of the issue affected types.
Theoretically this will work, but its never a bad thing to add an explicit test to demonstrate that the issue is resolved. But other than that, this looks great! Such a speedy resolution of a rather opaque issue 🚀
ndrluis
commented
Jun 25, 2024
Thank you, @syun64. I have added the test and used an existing metadata definition to avoid duplication. Regarding the solution, to be honest, it was not quick. It took me several weeks of learning and then stepping away from the problem for a few weeks to return with fresh ideas on how to solve it. |
sungwy
commented
Jun 25, 2024
5bad46b to
db8b151Compare
kevinjqliu
left a comment
There was a problem hiding this comment.
Thanks for addressing this 🐛!
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
db8b151 to
4fb7090Compare4fb7090 to
76127a5Comparendrluis
commented
Jun 26, 2024
Fokko
commented
Jun 26, 2024
@ndrluis Thanks for pinging me here. This approval should be gone once the first PR has been merged. Which should be soon 🚀 |
Fokko
commented
Jun 27, 2024
Thanks @ndrluis for working on this, and @syun64, @kevinjqliu and @HonahX for the quick review 🚀 |

The IcebergRootModel inherits from Pydantic RootModel, which has its own implementation of deepcopy. When deepcopy runs, it calls this
__deepcopy__method and ignores that it's a Singleton. So, my solution was to change the order of inheritance and implement a__deepcopy__method for singletons that returns itself.https://github.com/pydantic/pydantic/blob/f024d03b832d1bbcbadf76184ed14d92571a71ca/pydantic/root_model.py#L108-L116