We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 43a5ec2 commit b666d5aCopy full SHA for b666d5a
_patches/WvcLib.scala
@@ -32,4 +32,21 @@ object WvcLib extends LogSupport:
32
*/
33
@exported("wvlet_compile_query")
34
def compile_query(queryJson: CString): CString =
35
- stackalloc[CChar]((1024)).asInstanceOf[CString]
+ try
36
+ val json = fromCString(queryJson)
37
+ val query = MessageCodec.of[String].fromJson(json)
38
+ val args = Array("-q", query, "-x")
39
+ val (sql, _) = WvcMain.compileWvletQuery(args)
40
+
41
+ val buffer = stackalloc[CChar](sql.length + 1)
42
+ var i = 0
43
+ while (i < sql.length) {
44
+ buffer(i) = sql.charAt(i).toByte
45
+ i += 1
46
+ }
47
+ buffer(sql.length) = 0.toByte
48
+ buffer.asInstanceOf[CString]
49
+ catch
50
+ case e: Throwable =>
51
+ warn(e)
52
+ stackalloc[CChar](1).asInstanceOf[CString]
0 commit comments