You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if there's an issue here somewhere or me just misunderstanding how to do this properly, I'm generating a python relation where one of the columns is created via gen_random_uuid(), e.g.:
importduckdbdb=duckdb.connect()
my_relation=db.sql("select gen_random_uuid() as id, 'hello' as some_col")
Just printing this relation out gives me a consistent UUID each time:
I assume this has to do with the python relational API's lazy evaluation? If I create a table (like with to_table("some_name")) and then select from that table the problem goes away, so it seems like the two possible ways to get around this are:
Immediately turn the relation into a dataframe, and then back into a relation by selecting from it
my_relation_df=my_relation.df()
my_relation=db.sql("select * from my_relation_df")
Convert the relation to a table and then get it as a relation or just use the table name in later queries
db.sql("select * from my_relation").to_table("temp_relation_table")
my_relation=db.table("temp_relation_table")
But I'm curious if I'm missing something obvious/is there a better or conventional way of dealing with this? This problem is coming up because I have multiple queries later on working with my_relation, and combining all those results into a final relation that actually gets written as a table, but each later query is incorrectly working with a different set of UUIDs. Is it considered bad practice to create temporary relations like this instead of always making them actual tables and doing any processing on the tables themselves?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm not sure if there's an issue here somewhere or me just misunderstanding how to do this properly, I'm generating a python relation where one of the columns is created via
gen_random_uuid(), e.g.:Just printing this relation out gives me a consistent UUID each time:
However, if I interact with the relation in any other way (select from it, or call
df()on it), the UUID gets regenerated each time:I assume this has to do with the python relational API's lazy evaluation? If I create a table (like with
to_table("some_name")) and then select from that table the problem goes away, so it seems like the two possible ways to get around this are:But I'm curious if I'm missing something obvious/is there a better or conventional way of dealing with this? This problem is coming up because I have multiple queries later on working with
my_relation, and combining all those results into a final relation that actually gets written as a table, but each later query is incorrectly working with a different set of UUIDs. Is it considered bad practice to create temporary relations like this instead of always making them actual tables and doing any processing on the tables themselves?Beta Was this translation helpful? Give feedback.
All reactions