-
I have several tables in an MSSQL database where the id field is configured as Everything ChatGPT has suggested fails for one reason or another. I tried running the migration on a small table with the defaults and this char(36) appears as I've tried using Microsoft's DTSWizard on one table but I cancelled the process on account of it taking too long. Trino is supposedly much faster hence here I am. Here are some of the suggestions from ChatGPT that I've tried already: Suggestion 1:
Result 1:
Suggestion 2:
Result2:
Suggestion 3:
Result 3:
Suggestion 4:
Result 4:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
The docs are not ideal. You can cast to UUID from:
So the following works as expected:
EDIT: To make it even more clear, the only bit you need is |
Beta Was this translation helpful? Give feedback.
-
@ebyhr is there any good reason to not implement a cast from char to UUID since it's effectively same semantics as casting from a varchar? |
Beta Was this translation helpful? Give feedback.
-
Is there no way this can be done using CTAS? ChatGPT had already suggested what you too suggested, but I discounted that as an answer to my question. I believe Microsoft's DTSWizard also uses that method - to create the database first then do the data insertion. However, that method is very slow taking over 80 minutes for a small table with just over 30GB's of data. Trino with CTAS does it in under 20 minutes hence the reason I'd prefer to stick with CTAS. If you can show me how to use insert similar to CTAS and it is just as fast as CTAS, then maybe I'm amenable to changing all the current scripts. Otherwise, I'll just bite the bullet and do the char(36) to uuid conversion after migration. Apologies. I had to unmark your suggestion as the answer as that wasn't the question. If it cannot be done with the CTAS command, I'll adjust my expectations. |
Beta Was this translation helpful? Give feedback.
-
Oh my, apologies @hashhar. I just realized that with CTAS, I can do the double cast and it works as I was hoping. So this works:
As such, I have toggled your first response as the answer. It wasn't very clear on first read but now I get it. |
Beta Was this translation helpful? Give feedback.
The docs are not ideal.
You can cast to UUID from:
So the following works as expected:
EDIT: To make it even more clear, the only bit you need is
CAST(CAST(col AS VARCHAR) AS UUID)
…