99#include " duckdb/common/types/value.hpp"
1010#include " duckdb/function/table_function.hpp"
1111#include " duckdb/parser/parsed_data/create_table_function_info.hpp"
12-
12+ # include " query_farm_telemetry.hpp "
1313
1414#include " quickjs.h"
1515
@@ -194,7 +194,7 @@ class QuickJSTableBindData : public TableFunctionData {
194194public:
195195 QuickJSTableBindData () {
196196 }
197-
197+
198198 std::string js_code;
199199 vector<Value> parameters;
200200};
@@ -258,7 +258,8 @@ static void QuickJSEval(DataChunk &args, ExpressionState &state, Vector &result)
258258
259259 // Convert to std::string to ensure proper null-termination and avoid string_t inline storage issues
260260 std::string script_str = script_data[i].GetString ();
261- QuickJSValue func (ctx, JS_Eval (ctx, script_str.c_str (), script_str.length (), " <eval>" , JS_EVAL_TYPE_GLOBAL | JS_EVAL_FLAG_STRICT));
261+ QuickJSValue func (ctx, JS_Eval (ctx, script_str.c_str (), script_str.length (), " <eval>" ,
262+ JS_EVAL_TYPE_GLOBAL | JS_EVAL_FLAG_STRICT));
262263
263264 if (func.IsException ()) {
264265 ThrowJSException (ctx);
@@ -312,7 +313,8 @@ static void QuickJSExecute(DataChunk &args, ExpressionState &state, Vector &resu
312313
313314 // Convert to std::string to ensure proper null-termination and avoid string_t inline storage issues
314315 std::string script_str = script.GetString ();
315- QuickJSValue val (ctx, JS_Eval (ctx, script_str.c_str (), script_str.length (), " <eval>" , JS_EVAL_TYPE_GLOBAL | JS_EVAL_FLAG_STRICT));
316+ QuickJSValue val (ctx, JS_Eval (ctx, script_str.c_str (), script_str.length (), " <eval>" ,
317+ JS_EVAL_TYPE_GLOBAL | JS_EVAL_FLAG_STRICT));
316318
317319 if (val.IsException ()) {
318320 ThrowJSException (ctx);
@@ -361,7 +363,7 @@ static unique_ptr<FunctionData> QuickJSTableBind(ClientContext &context, TableFu
361363 names.push_back (" result" );
362364
363365 auto bind_data = make_uniq<QuickJSTableBindData>();
364-
366+
365367 // Extract the JavaScript code from the first argument
366368 if (!input.inputs [0 ].IsNull ()) {
367369 bind_data->js_code = input.inputs [0 ].GetValue <string>();
@@ -392,7 +394,8 @@ static unique_ptr<GlobalTableFunctionState> QuickJSTableInit(ClientContext &cont
392394 // Create a function that takes the parameters and returns the result
393395 std::string js_function_code = " (function(" ;
394396 for (idx_t i = 0 ; i < bind_data.parameters .size (); i++) {
395- if (i > 0 ) js_function_code += " , " ;
397+ if (i > 0 )
398+ js_function_code += " , " ;
396399 js_function_code += " arg" + std::to_string (i);
397400 }
398401 js_function_code += " ) { " ;
@@ -405,7 +408,8 @@ static unique_ptr<GlobalTableFunctionState> QuickJSTableInit(ClientContext &cont
405408 js_function_code += " return " + bind_data.js_code + " ; })" ;
406409
407410 // Compile the function
408- QuickJSValue func_val (ctx, JS_Eval (ctx, js_function_code.c_str (), js_function_code.length (), " <eval>" , JS_EVAL_TYPE_GLOBAL | JS_EVAL_FLAG_STRICT));
411+ QuickJSValue func_val (ctx, JS_Eval (ctx, js_function_code.c_str (), js_function_code.length (), " <eval>" ,
412+ JS_EVAL_TYPE_GLOBAL | JS_EVAL_FLAG_STRICT));
409413 if (func_val.IsException ()) {
410414 ThrowJSException (ctx, " Failed to compile JavaScript function" );
411415 }
@@ -465,8 +469,7 @@ static void LoadInternal(ExtensionLoader &loader) {
465469 // ===--------------------------------------------------------------------===//
466470 ScalarFunctionSet quickjs_set (" quickjs" );
467471
468- auto quickjs_scalar_function =
469- ScalarFunction ({LogicalType::VARCHAR}, LogicalType::VARCHAR, QuickJSExecute);
472+ auto quickjs_scalar_function = ScalarFunction ({LogicalType::VARCHAR}, LogicalType::VARCHAR, QuickJSExecute);
470473 quickjs_scalar_function.stability = FunctionStability::VOLATILE;
471474 quickjs_set.AddFunction (quickjs_scalar_function);
472475
@@ -486,15 +489,15 @@ static void LoadInternal(ExtensionLoader &loader) {
486489 // ===--------------------------------------------------------------------===//
487490 ScalarFunctionSet quickjs_eval_set (" quickjs_eval" );
488491
489- auto quickjs_eval_function =
490- ScalarFunction ({LogicalType::VARCHAR}, LogicalType::JSON (), QuickJSEval);
492+ auto quickjs_eval_function = ScalarFunction ({LogicalType::VARCHAR}, LogicalType::JSON (), QuickJSEval);
491493 quickjs_eval_function.varargs = LogicalType::ANY;
492494 quickjs_eval_function.stability = FunctionStability::VOLATILE;
493495 quickjs_eval_set.AddFunction (quickjs_eval_function);
494496
495497 CreateScalarFunctionInfo quickjs_eval_info (quickjs_eval_set);
496498 FunctionDescription quickjs_eval_desc;
497- quickjs_eval_desc.description = " Execute a JavaScript function with the provided arguments and return the result as JSON" ;
499+ quickjs_eval_desc.description =
500+ " Execute a JavaScript function with the provided arguments and return the result as JSON" ;
498501 quickjs_eval_desc.parameter_types = {LogicalType::VARCHAR};
499502 quickjs_eval_desc.parameter_names = {" function" };
500503 quickjs_eval_desc.examples = {" quickjs_eval('(a, b) => a + b', 1, 2)" , " quickjs_eval('(x) => x * 2', 21)" };
@@ -508,7 +511,8 @@ static void LoadInternal(ExtensionLoader &loader) {
508511 // ===--------------------------------------------------------------------===//
509512 TableFunctionSet quickjs_table_set (" quickjs" );
510513
511- auto quickjs_table_function = TableFunction ({LogicalType::VARCHAR}, QuickJSTableFunction, QuickJSTableBind, QuickJSTableInit);
514+ auto quickjs_table_function =
515+ TableFunction ({LogicalType::VARCHAR}, QuickJSTableFunction, QuickJSTableBind, QuickJSTableInit);
512516 quickjs_table_function.varargs = LogicalType::ANY;
513517 quickjs_table_set.AddFunction (quickjs_table_function);
514518
@@ -522,6 +526,8 @@ static void LoadInternal(ExtensionLoader &loader) {
522526 quickjs_table_info.descriptions .push_back (quickjs_table_desc);
523527
524528 loader.RegisterFunction (quickjs_table_info);
529+
530+ QueryFarmSendTelemetry (loader, " quickjs" , " 2025120401" );
525531}
526532
527533void QuickjsExtension::Load (ExtensionLoader &loader) {
0 commit comments