Is it possible in Dremio to cast one column data type into the other (both directions). If so, how do you do it without changing the content but just the data type? Since SQL does not support implicit casting for these two data types (fair enough) how do you explicitly do it? We gave it a try using the convert_from/to functions without success.
In the image below you can see some example values. We would like to be able to represent the same sequence of characters using varbinary or varchar.
Here’s an example of a SQL Server uniqueidentifier value: 5740191A-363C-4FFA-942B-A547131AFDFC
Does anyone has a resolution to this issue?
We pull JSON data from Azure Data Lake containing unqueidentifiers. Dremio pulls these values as varchar data types. We want to join this data to data we pull from SQL Server (where uniqueidentifiers are pulled as varbinary).
I don’t get an error, but I also don’t get a value that will match across sources.
I either need to be able to convert a UniqueIdentifier contained in a VARCHAR field to a BINARY value that will match what Dremio is creating for SQL Server UniqueIdentifier columns, or I need a way to convert the value Dremio returns from a SQL UniqueIdentifier column into a VARCHAR that matches the original UniqueIdentifier string (xxxxxxxx-xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
Unless there is a way to modify how Dremio is interpreting a SQL UniqueIdentifier column. I could use a view on the SQL side to cast the UID to a VARCHAR and then pull the data from the view, but then any predicates pushed to SQL by Dremio would not be able to utilize any indexing on the UniqueIdentifier column.
From experimenting with different functions, for the uniqueidentifier ‘A831071E-E183-44D5-B597-0A87F2E3F3F8’ from the sql server dremio get the VARBINARY ‘HgcxqIPh1US1lwqH8uPz+A==’ or this is what i can see in the web ui.
If I use the to_hex function the resulting value is ‘1E0731A883E1D544B5970A87F2E3F3F8’
well if you observe closely it seems that its every character from the original uniqueidentifier expept sufled and with the ‘-’ character missing.
We solve this issue by implementing our own StringFunction and recompile the Dremio code with it.
We simply rearrange the characters in the string and add ‘-’ where is needed.
File: StringFunctions.java
Thank you for your response. I don’t have the option to add the function at this time, but your answer led me to the Dremio SQL version of it. Here it is if anyone else needs it. I’m sure it’s very inefficient, but it does the job. My opinion something like this function should be included, or an option to read them like this from the source. Our users are used to seeing the UUID’s in this format, and will be very confused if they don’t look like this.