{"id":17778,"date":"2025-12-18T10:00:32","date_gmt":"2025-12-18T18:00:32","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=17778"},"modified":"2026-01-06T14:28:01","modified_gmt":"2026-01-06T22:28:01","slug":"talk-to-your-data-a-udf-that-speaks-your-language","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/ko\/talk-to-your-data-a-udf-that-speaks-your-language\/","title":{"rendered":"Talk to Your Data: A UDF That Speaks Your Language"},"content":{"rendered":"<pre class=\"lang:default decode:true\">SELECT u.name, COUNT(o.id) AS total_orders\r\nFROM `commerce`.sales.users AS u\r\nJOIN `commerce`.sales.orders AS o ON u.id = o.user_id\r\nWHERE o.status = \"completed\"\r\nAND DATE_DIFF_STR(NOW_STR(), o.order_date, \"day\") &lt;= 30\r\nGROUP BY u.name\r\nORDER BY total_orders DESC\r\nLIMIT 5;\r\n<\/pre>\n<p><span style=\"font-weight: 400\">The query above provides valuable insights from your data that&#8217;s stored in Couchbase about your top five users who generated the most completed orders within the past 30 days. But what if you\u2019re not an advanced SQL++ developer and need the answers by 11 p.m. for a report? You then need to wait for a developer to write a SQL++ query and get you the answers.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Alternatively, consider a case where you need to do some ad hoc debugging to address questions like:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Are there any documents where the date the order was delivered is missing?<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Does that mean that the order was cancelled? Or did we misplace the order and the order never got delivered? Or was everything ok, but we simply missed adding the order_delivered value in the field?<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">In this case, you not only need to search the\u00a0 order_delivered field, but also look at order_cancelled or investigate comments to figure out if it was misplaced, etc. So the query to be written isn\u2019t simple or straightforward.\u00a0<\/span><\/p>\n<pre class=\"lang:default decode:true\">SELECT \r\n    o.orderId,\r\n    o.orderDate,\r\n    o.order_cancelled,\r\n    o.order_delivered,\r\n    o.comments,\r\n    \r\n    CASE\r\n        WHEN o.order_cancelled = TRUE THEN \"Order was cancelled\"\r\n        WHEN ANY c IN o.comments SATISFIES LOWER(c) LIKE \"%misplac%\" \r\n                                    OR LOWER(c) LIKE \"%lost%\" THEN \"Order may have been misplaced\"\r\n        WHEN ANY c IN o.comments SATISFIES LOWER(c) LIKE \"%deliver%\" THEN \"Delivered but field not updated\"\r\n        ELSE \"Reason unknown \u2014 investigate\"\r\n    END AS reason\r\nFROM `commerce`.`sales`.`orders` AS o\r\nWHERE o.order_delivered IS MISSING OR o.order_delivered IS NULL;\r\n<\/pre>\n<p><span style=\"font-weight: 400\">In such cases, it would help if you had a reliable assistant available 24&#215;7 to get all these answers. The UDF described in this blog is such an assistant. It accepts your questions in the most natural way and returns results in JSON. Behind the scenes, it connects to a model of your choice, along with your API key, to convert your thoughts into SQL++ and then executes it. And all you need to invoke this assistant is to use the UDF.<\/span><\/p>\n<pre class=\"lang:default decode:true\">SELECT NL2SQL(\r\n  [\u201c`commerce`.`sales`.`orders`\u201d],\r\n  \"Are there any documents where the order_delivered date is missing?and if so why?\",\r\n  \"\",\r\n  \"https:\/\/api.openai.com\/v1\/chat\/completions\",\r\n  \"gpt-4o-2024-05-13\"\r\n) ;\r\n<\/pre>\n<h3><b>\uc791\ub3d9 \ubc29\uc2dd<\/b><\/h3>\n<p><span style=\"font-weight: 400\">1. <b>Set up the library.<\/b><br \/>\nYou first create a JavaScript library used by the UDF.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Library:<\/span><\/p>\n<pre class=\"lang:default decode:true\">\/*\r\ninput:\r\n\r\nkeyspaces: an array of strings, each string represents a keyspaces \"bucket.scope.collection\" with proper escaping using grave-accent quote wherever required\r\nprompt: users natural language request\r\napikey: your openai api key\r\nmodel: string representing the model's name, see https:\/\/platform.openai.com\/docs\/api-reference\/completions\/create#completions-create-model for more details\r\n \r\noutput:\r\nchat-completions api response with the generated sql statement\r\n*\/\r\n \r\n \r\n \r\nfunction inferencer(k) {\r\n   var infq = N1QL(\"SELECT t.properties FROM(INFER \"+k+ \") as t\") ;\r\n   var res=[]\r\n   for(const doc of infq) {\r\n       res.push(doc)\r\n   }\r\n  \r\n    return res[0];\r\n}\r\n \r\n \r\nfunction nl2sql(keyspaces, prompt, apikey, modelapi, model) {\r\n  \r\n   \r\n   collectionSchema = {}\r\n   for(const k in keyspaces) {\r\n       c = inferencer(keyspaces[k])\r\n       collectionSchema[keyspaces[k]] = c\r\n   }\r\n  \r\n   collectionSchemaStr = JSON.stringify(collectionSchema)\r\n  \r\n   promptContent = `Information:\\nCollection's schema: ${collectionSchemaStr}\\n\\nPrompt: \\\"${prompt}\\\"\\n\\nThe query context is set.\\n\\nBased on the above Information, write valid SQL++ and return only the statement and no explanation. For retrieval, use aliases. Use UNNEST from the FROM clause when appropriate. \\n\\nIf you're sure the Prompt can't be used to generate a query, first say \\\"#ERR:\\\" and then explain why not.`\r\n  \r\n    \r\n    data = {\"messages\":[{\"role\":\"system\",\"content\":\"You are a Couchbase Capella expert. Your task is to create valid queries to retrieve or create data based on the provided Information.\\n\\nApproach this task step-by-step and take your time.\"},{\"role\":\"user\",\"content\":promptContent}],\r\n        \"model\": model,\r\n        \"temperature\":0,\r\n        \"max_tokens\":1024,\r\n        \"stream\":false}\r\n\r\n    \r\n    \r\nvar dataStr = JSON.stringify(data)\r\n    .replace(\/\\\\\/g, \"\\\\\\\\\")    \/\/ escape backslashes\r\n    .replace(\/\"\/g, '\\\\\"');     \/\/ escape quotes\r\n   \r\n    var completionsurl = modelapi\r\n  \r\n   var q= `SELECT CURL(\"${completionsurl}\", {\r\n        \"request\": \"POST\",\r\n        \"header\": [\"Authorization: Bearer ${apikey}\", \"Content-type: application\/json\"],\r\n        \"data\": \"${dataStr}\"\r\n    }) AS result;`\r\n   \r\n    var completionsq = N1QL(q);\r\n       \r\n    \r\n \r\n    var res = []\r\n   for(const doc of completionsq) {\r\n       res.push(doc);\r\n     }\r\n   \r\n  try {\r\n    content = res[0].result.choices[0].message.content    \r\n  } catch(e) {\r\n    return res;  \r\n  } \r\n   \r\n  stmt = content.trim().substring(7, content.length-4)\r\n   \r\n  isSelect = (stmt.substring(0,6).toLowerCase())===\"select\"\r\n  if(isSelect === false){\r\n      return {\r\n          \"generated_statement\": stmt\r\n      }\r\n  }\r\n  \r\n  var runq = N1QL(stmt);\r\n   \r\n   var rrun = []\r\n  for(const doc of runq) {\r\n      rrun.push(doc)\r\n  }\r\n  \r\n  return {\r\n      \"generated_statement\": stmt,\r\n      \"results\": rrun\r\n  }\r\n    \r\n}\r\n<\/pre>\n<p><span style=\"font-weight: 400;padding-bottom: 12px\">2. <b>Upload the library.<\/b><br \/>\nRun the curl command after copying the provided library code into a file, i.e., usingailib.js. <\/span><\/p>\n<pre class=\"lang:default decode:true\">curl -X POST https:\/\/localhost:9499\/evaluator\/v1\/libraries\/usingailib \r\n--data-binary @usingailib.js -u Administrator:password<\/pre>\n<p><span style=\"font-weight: 400;padding-bottom: 12px\">3. <b>Create the UDF.<\/b><br \/>\nUse the create function statement below to create the UDF once you have created the library:<\/span><\/p>\n<pre class=\"lang:default decode:true\">CREATE OR REPLACE FUNCTION NL2SQL(keyspaces, prompt, apikey, modelapi, model) \r\nLANGUAGE JAVASCRIPT AS \"nl2sql\" AT \"usingailib\";<\/pre>\n<p><span style=\"font-weight: 400\">NL2SQL() now acts as your multilingual translator between human language and Couchbase\u2019s query engine. You simply give it some context and a natural language request, and it returns a response.<\/span><\/p>\n<h3>How the UDF Thinks<\/h3>\n<p><span style=\"font-weight: 400\">Under the hood, it uses your preferred model when invoking the UDF to understand your intent and generate a query that Couchbase can execute.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The advantage of using the chat completions API means you could simply plug in a model from other providers that are compliant with the same API spec. You can use your own private LLM or known ones from Open AI, Gemini, Claude, etc.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The invoked UDF requires the following information from you:<\/span><\/p>\n<ol type=\"I\">\n<li><em>\ud0a4 \uc2a4\ud398\uc774\uc2a4<\/em> \u2013 An array of strings, each representing a Couchbase keyspace (bucket.scope.collection).Use grave accent quotes where needed to escape special names (like `travel-sample`.inventory.route). This tells the UDF where to look for your data.<\/li>\n<li><em>\ud504\ub86c\ud504\ud2b8<\/em> \u2013 Your request in plain English (or any other language).<br \/>\nExample: &#8220;Show me all users who made a purchase in the last 24 hours.&#8221;<\/li>\n<li><em>apikey<\/em> \u2013 Your API key used for authenticating with the model endpoint.<\/li>\n<li><em>model endpoint<\/em> \u2013 e.g., Open AI compliant chat completions URL.<\/li>\n<li><em>\ubaa8\ub378<\/em> \u2013 The name of the model you want to use from the provider.<br \/>\ne.g., &#8220;gpt-4o-2024-05-13&#8221;<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">There are also several available functions in the library:<\/span><\/p>\n<p><strong>inferencer()<\/strong><\/p>\n<p>Before generating a query, the UDF first tries to understand your data. The inferencer() helper function calls Couchbase\u2019s INFER statement to retrieve a collection\u2019s schema:<\/p>\n<pre class=\"lang:default decode:true\">function inferencer(k) {\r\n   var infq = N1QL(\"SELECT t.properties FROM (INFER \" + k + \") AS t\");\r\n   var res = [];\r\n   for (const doc of infq) {\r\n       res.push(doc);\r\n   }\r\n   return res[0];\r\n}\r\n<\/pre>\n<p>This schema is used to help the AI understand what kind of data lives inside each collection.<\/p>\n<p><strong>The main function: nl2sql()<\/strong><\/p>\n<ul>\n<li>Collects all schemas for the given keyspaces using the inferencer(). Constructs a prompt that includes: the inferred schema, your natural language query, and a Couchbase prompt to nudge the LLM.<\/li>\n<li>Sends it to the LLM.<\/li>\n<li>Extracts the generated SQL++ from the model\u2019s response.<\/li>\n<li>Executes it directly if it\u2019s a SELECT statement and returns both the generated SQL++ statement and the query results.<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">The reason for not executing non-select statements is that you don\u2019t want this UDF to insert, update, or delete documents in a collection without you verifying it. So the SQL++ statement lets you execute it after it\u2019s been verified.<\/span><\/p>\n<p>Example use case:<\/p>\n<pre class=\"lang:default decode:true\">SELECT default:NL2SQL(\r\n  [\"`travel-sample`.inventory.hotel\"],\r\n  \"Give me hotels in San Francisco that have free parking and free breakfast and a rating of more than 3\",  \"\",\r\n  \"https:\/\/api.openai.com\/v1\/chat\/completions\",\r\n  \"gpt-4o-2024-05-13\"\r\n);\r\n<\/pre>\n<pre class=\"lang:default decode:true\">Result:\r\n[{\r\n    \"$1\": {\r\n        \"generated_statement\": \"SELECT h.name, h.address, h.city, h.state, h.country, h.free_parking, h.free_breakfast, r.ratings.Overall\\nFROM `travel-sample`.inventory.hotel AS h\\nUNNEST h.reviews AS r\\nWHERE h.city = \\\"San Francisco\\\"\\n  AND h.free_parking = true\\n  AND h.free_breakfast = true\\n  AND r.ratings.Overall &gt; 3;\",\r\n        \"results\": [{\r\n                \"Overall\": 4,\r\n                \"address\": \"520 Church St\",\r\n                \"city\": \"San Francisco\",\r\n                \"country\": \"United States\",\r\n                \"free_breakfast\": true,\r\n                \"free_parking\": true,\r\n                \"name\": \"Parker House\",\r\n                \"state\": \"California\"\r\n            },\r\n            {\r\n                \"Overall\": 4,\r\n                \"address\": \"520 Church St\",\r\n                \"city\": \"San Francisco\",\r\n                \"country\": \"United States\",\r\n                \"free_breakfast\": true,\r\n                \"free_parking\": true,\r\n                \"name\": \"Parker House\",\r\n                \"state\": \"California\"\r\n            },\r\n            {\r\n                \"Overall\": 5,\r\n                \"address\": \"520 Church St\",\r\n                \"city\": \"San Francisco\",\r\n                \"country\": \"United States\",\r\n                \"free_breakfast\": true,\r\n                \"free_parking\": true,\r\n                \"name\": \"Parker House\",\r\n                \"state\": \"California\"\r\n            },\r\n            {\r\n                \"Overall\": 4,\r\n                \"address\": \"520 Church St\",\r\n                \"city\": \"San Francisco\",\r\n                \"country\": \"United States\",\r\n                \"free_breakfast\": true,\r\n                \"free_parking\": true,\r\n                \"name\": \"Parker House\",\r\n                \"state\": \"California\"\r\n            },\r\n            {\r\n                \"Overall\": 5,\r\n                \"address\": \"465 Grant Ave\",\r\n                \"city\": \"San Francisco\",\r\n                \"country\": \"United States\",\r\n                \"free_breakfast\": true,\r\n                \"free_parking\": true,\r\n                \"name\": \"Grant Plaza Hotel\",\r\n                \"state\": \"California\"\r\n            },\r\n            {\r\n                \"Overall\": 5,\r\n                \"address\": \"465 Grant Ave\",\r\n                \"city\": \"San Francisco\",\r\n                \"country\": \"United States\",\r\n                \"free_breakfast\": true,\r\n                \"free_parking\": true,\r\n                \"name\": \"Grant Plaza Hotel\",\r\n                \"state\": \"California\"\r\n            },\r\n...\r\n<\/pre>\n<h3>Experimenting with models from other providers<\/h3>\n<p>The next example uses Gemini\u2019s Open AI-compatible API. You simply change the model provider\u2019s URL from the previous Open AI API to Gemini\u2019s API. Also, be sure to change the model parameter to a model it recognizes. Of course, you need to also update the api-key from Open AI\u2019s key to Gemini\u2019s key.<\/p>\n<pre class=\"lang:default decode:true\">SELECT NL2SQL(\r\n  [\"`travel-sample`.inventory.hotel\"],\r\n  \"Show me hotels in France\",\r\n  \"\",\r\n  \"https:\/\/generativelanguage.googleapis.com\/v1beta\/openai\/chat\/completions\",\r\n  \"gemini-2.0-flash\"\r\n)as p;\r\n<\/pre>\n<p>The following illustrates the result:<\/p>\n<pre class=\"lang:default decode:true\">[{\r\n    \"p\": {\r\n        \"generated_statement\": \"SELECT h.name AS hotel_name, h.city AS hotel_city\\nFROM `travel-sample`.inventory.hotel AS h\\nWHERE h.country = \\\"France\\\";\",\r\n        \"results\": [{\r\n                \"hotel_city\": \"Giverny\",\r\n                \"hotel_name\": \"The Robins\"\r\n            },\r\n            {\r\n                \"hotel_city\": \"Giverny\",\r\n                \"hotel_name\": \"Le Clos Fleuri\"\r\n            },\r\n \t\u2026\r\n\t     {\r\n                \"hotel_city\": \"Ferney-Voltaire\",\r\n                \"hotel_name\": \"Hotel Formule 1\"\r\n            }\r\n        ]\r\n    }\r\n}]\r\n<\/pre>\n<h3>\uacb0\ub860<\/h3>\n<p>This blog provides a glimpse into how you can leverage AI to interact with your data in Couchbase. With this UDF, natural language querying becomes a reality &#8211; no SQL++ expertise required. It is model-agnostic and safe for production queries.<\/p>\n<p>And this is just the beginning. In the future, we hope to extend it to:<\/p>\n<ul>\n<li>Image \u2192 SQL++<\/li>\n<li>Voice \u2192 SQL++<\/li>\n<li>Agent-like pipelines<\/li>\n<\/ul>\n<p>\u2026 all running inside Couchbase workflows.<\/p>\n<p><strong>\ucc38\uc870<\/strong><br \/>\nCapella IQ: <a href=\"https:\/\/docs.couchbase.com\/cloud\/get-started\/capella-iq\/get-started-with-iq.html\">https:\/\/docs.couchbase.com\/cloud\/get-started\/capella-iq\/get-started-with-iq.html<\/a><br \/>\nChat completions APIs:<br \/>\n<a href=\"https:\/\/platform.openai.com\/docs\/api-reference\/chat\">https:\/\/platform.openai.com\/docs\/api-reference\/chat<\/a><br \/>\n<a href=\"https:\/\/ai.google.dev\/gemini-api\/docs\/openai#rest\">https:\/\/ai.google.dev\/gemini-api\/docs\/openai#rest<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>SELECT u.name, COUNT(o.id) AS total_orders FROM `commerce`.sales.users AS u JOIN `commerce`.sales.orders AS o ON u.id = o.user_id WHERE o.status = &#8220;completed&#8221; AND DATE_DIFF_STR(NOW_STR(), o.order_date, &#8220;day&#8221;) &lt;= 30 GROUP BY u.name ORDER BY total_orders DESC LIMIT 5; The query above provides [&hellip;]<\/p>","protected":false},"author":84423,"featured_media":17784,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1816],"tags":[],"ppma_author":[9835],"class_list":["post-17778","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-couchbase-server"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.5 (Yoast SEO v26.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Talk to Your Data: A UDF That Speaks Your Language - The Couchbase Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/ko\/talk-to-your-data-a-udf-that-speaks-your-language\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Talk to Your Data: A UDF That Speaks Your Language\" \/>\n<meta property=\"og:description\" content=\"SELECT u.name, COUNT(o.id) AS total_orders FROM `commerce`.sales.users AS u JOIN `commerce`.sales.orders AS o ON u.id = o.user_id WHERE o.status = &quot;completed&quot; AND DATE_DIFF_STR(NOW_STR(), o.order_date, &quot;day&quot;) &lt;= 30 GROUP BY u.name ORDER BY total_orders DESC LIMIT 5; The query above provides [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/ko\/talk-to-your-data-a-udf-that-speaks-your-language\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2025-12-18T18:00:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-06T22:28:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/12\/Talk-to-Your-Data_-A-UDF-That-Speaks-Your-Language-1-1024x536.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"536\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Gaurav Jayaraj - Software Engineer\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Gaurav Jayaraj - Software Engineer\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/\"},\"author\":{\"name\":\"Gaurav Jayaraj - Software Engineer\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/546cec92f77cbb0b09f9b973fd1c8d42\"},\"headline\":\"Talk to Your Data: A UDF That Speaks Your Language\",\"datePublished\":\"2025-12-18T18:00:32+00:00\",\"dateModified\":\"2026-01-06T22:28:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/\"},\"wordCount\":868,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/12\/Talk-to-Your-Data_-A-UDF-That-Speaks-Your-Language-1.png\",\"articleSection\":[\"Couchbase Server\"],\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/\",\"name\":\"Talk to Your Data: A UDF That Speaks Your Language - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/12\/Talk-to-Your-Data_-A-UDF-That-Speaks-Your-Language-1.png\",\"datePublished\":\"2025-12-18T18:00:32+00:00\",\"dateModified\":\"2026-01-06T22:28:01+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/12\/Talk-to-Your-Data_-A-UDF-That-Speaks-Your-Language-1.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/12\/Talk-to-Your-Data_-A-UDF-That-Speaks-Your-Language-1.png\",\"width\":2400,\"height\":1256},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Talk to Your Data: A UDF That Speaks Your Language\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/546cec92f77cbb0b09f9b973fd1c8d42\",\"name\":\"Gaurav Jayaraj - Software Engineer\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/a332e5d7f47865015367ca88af3e5891\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/02\/unnamed-2.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/02\/unnamed-2.jpg\",\"caption\":\"Gaurav Jayaraj - Software Engineer\"},\"description\":\"Gaurav Jayaraj is an intern in the Query team at Couchbase R&amp;D. Gaurav is pursuing his Bachelors in Computer Science from PES University, Bangalore.\",\"url\":\"https:\/\/www.couchbase.com\/blog\/ko\/author\/gauravjayaraj\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Talk to Your Data: A UDF That Speaks Your Language - The Couchbase Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/ko\/talk-to-your-data-a-udf-that-speaks-your-language\/","og_locale":"ko_KR","og_type":"article","og_title":"Talk to Your Data: A UDF That Speaks Your Language","og_description":"SELECT u.name, COUNT(o.id) AS total_orders FROM `commerce`.sales.users AS u JOIN `commerce`.sales.orders AS o ON u.id = o.user_id WHERE o.status = \"completed\" AND DATE_DIFF_STR(NOW_STR(), o.order_date, \"day\") &lt;= 30 GROUP BY u.name ORDER BY total_orders DESC LIMIT 5; The query above provides [&hellip;]","og_url":"https:\/\/www.couchbase.com\/blog\/ko\/talk-to-your-data-a-udf-that-speaks-your-language\/","og_site_name":"The Couchbase Blog","article_published_time":"2025-12-18T18:00:32+00:00","article_modified_time":"2026-01-06T22:28:01+00:00","og_image":[{"width":1024,"height":536,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/12\/Talk-to-Your-Data_-A-UDF-That-Speaks-Your-Language-1-1024x536.png","type":"image\/png"}],"author":"Gaurav Jayaraj - Software Engineer","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Gaurav Jayaraj - Software Engineer","Est. reading time":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/"},"author":{"name":"Gaurav Jayaraj - Software Engineer","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/546cec92f77cbb0b09f9b973fd1c8d42"},"headline":"Talk to Your Data: A UDF That Speaks Your Language","datePublished":"2025-12-18T18:00:32+00:00","dateModified":"2026-01-06T22:28:01+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/"},"wordCount":868,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/12\/Talk-to-Your-Data_-A-UDF-That-Speaks-Your-Language-1.png","articleSection":["Couchbase Server"],"inLanguage":"ko-KR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/","url":"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/","name":"Talk to Your Data: A UDF That Speaks Your Language - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/12\/Talk-to-Your-Data_-A-UDF-That-Speaks-Your-Language-1.png","datePublished":"2025-12-18T18:00:32+00:00","dateModified":"2026-01-06T22:28:01+00:00","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/"]}]},{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/12\/Talk-to-Your-Data_-A-UDF-That-Speaks-Your-Language-1.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/12\/Talk-to-Your-Data_-A-UDF-That-Speaks-Your-Language-1.png","width":2400,"height":1256},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/talk-to-your-data-a-udf-that-speaks-your-language\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Talk to Your Data: A UDF That Speaks Your Language"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"\uce74\uc6b0\uce58\ubca0\uc774\uc2a4 \ube14\ub85c\uadf8","description":"NoSQL \ub370\uc774\ud130\ubca0\uc774\uc2a4, Couchbase","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"\uce74\uc6b0\uce58\ubca0\uc774\uc2a4 \ube14\ub85c\uadf8","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/546cec92f77cbb0b09f9b973fd1c8d42","name":"\uac00\uc6b0\ub77c\ube0c \uc790\uc57c\ub77c\uc988 - \uc18c\ud504\ud2b8\uc6e8\uc5b4 \uc5d4\uc9c0\ub2c8\uc5b4","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/a332e5d7f47865015367ca88af3e5891","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/02\/unnamed-2.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/02\/unnamed-2.jpg","caption":"Gaurav Jayaraj - Software Engineer"},"description":"\uac00\uc6b0\ub77c\ube0c \uc790\uc57c\ub77c\uc988\ub294 \uce74\uc6b0\uce58\ubca0\uc774\uc2a4 R&amp;D\uc758 \ucffc\ub9ac \ud300\uc5d0\uc11c \uc778\ud134\uc73c\ub85c \uadfc\ubb34\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4. Gaurav\ub294 \ubc29\uac08\ub85c\ub974\uc758 PES \ub300\ud559\uc5d0\uc11c \ucef4\ud4e8\ud130 \uacf5\ud559 \ud559\uc0ac \ud559\uc704\ub97c \ucde8\ub4dd\ud588\uc2b5\ub2c8\ub2e4.","url":"https:\/\/www.couchbase.com\/blog\/ko\/author\/gauravjayaraj\/"}]}},"authors":[{"term_id":9835,"user_id":84423,"is_guest":0,"slug":"gauravjayaraj","display_name":"Gaurav Jayaraj - Software Engineer","avatar_url":{"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/02\/unnamed-2.jpg","url2x":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/02\/unnamed-2.jpg"},"author_category":"","last_name":"Jayaraj - Software Engineer","first_name":"Gaurav","job_title":"","user_url":"","description":"\uac00\uc6b0\ub77c\ube0c \uc790\uc57c\ub77c\uc988\ub294 \uce74\uc6b0\uce58\ubca0\uc774\uc2a4 R&amp;D\uc758 \ucffc\ub9ac \ud300\uc5d0\uc11c \uc778\ud134\uc73c\ub85c \uadfc\ubb34\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4. Gaurav\ub294 \ubc29\uac08\ub85c\ub974\uc758 PES \ub300\ud559\uc5d0\uc11c \ucef4\ud4e8\ud130 \uacf5\ud559 \ud559\uc0ac \ud559\uc704\ub97c \ucde8\ub4dd\ud588\uc2b5\ub2c8\ub2e4."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/posts\/17778","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/users\/84423"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/comments?post=17778"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/posts\/17778\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/media\/17784"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/media?parent=17778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/categories?post=17778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/tags?post=17778"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/ko\/wp-json\/wp\/v2\/ppma_author?post=17778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}