I want to add the new built-in function in OpenMLDB, called unhex
. The unhex
has the following action just like Spark SQL
and MySQL
.
Spark SQL:
spark-sql> select unhex(hex('Spark SQL'));
Spark SQL
Time taken: 2.163 seconds, Fetched 1 row(s)
spark-sql> select unhex(hex(14));
Time taken: 0.065 seconds, Fetched 1 row(s)
spark-sql> select unhex(hex(50));
2
Time taken: 0.056 seconds, Fetched 1 row(s)
spark-sql> select hex('Spark SQL');
537061726B2053514C
Time taken: 0.072 seconds, Fetched 1 row(s)
spark-sql> select unhex('537061726B2053514C');
Spark SQL
Time taken: 0.04 seconds, Fetched 1 row(s)
MySQL:
mysql> select hex('MySQL');
+--------------+
| hex('MySQL') |
+--------------+
| 4D7953514C |
+--------------+
1 row in set (0.00 sec)
mysql> select unhex('4D7953514C');
+---------------------+
| unhex('4D7953514C') |
+---------------------+
| MySQL |
+---------------------+
1 row in set (0.00 sec)
mysql> select unhex(hex('MySQL'));
+---------------------+
| unhex(hex('MySQL')) |
+---------------------+
| MySQL |
+---------------------+
1 row in set (0.00 sec)
mysql> select unhex(hex(14));
+----------------+
| unhex(hex(14)) |
+----------------+
| |
+----------------+
1 row in set (0.00 sec)
mysql> select unhex(hex(50));
+----------------+
| unhex(hex(50)) |
+----------------+
| 2 |
+----------------+
1 row in set (0.01 sec)
As you can see, the unhex
function can successfully unhex the String
but can't unhex the int or double. Weird.🤔🤔